diff --git a/htdocs/bookmarks/fiche.php b/htdocs/bookmarks/fiche.php index 9d26c0eeba2dc71b1fac39e22796e24081909c81..6414b119cc4f6c157e2e998e033cf6fd4986dae4 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?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle")); + if (! $url) $mesg.=($mesg?'<br>':'').$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='<div class="error">'.$bookmark->error.'</div>'; + $action='create'; + } } else { - $mesg='<div class="error">'.$bookmark->error.'</div>'; + $mesg='<div class="error">'.$mesg.'</div>'; + $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); + + +if ($action == 'create') +{ + /* + * Fiche bookmark en mode creation + */ + + print '<form action="fiche.php" method="post">'."\n"; + print '<input type="hidden" name="action" value="add">'; + + print_fiche_titre($langs->trans("NewBookmark")); + + if ($mesg) print "$mesg<br>"; -print 'En construction'; + print '<table class="border" width="100%">'; + print '<tr><td width="20%">'.$langs->trans("BookmarkTitle").'</td><td><input class="flat" name="title" size="30" value="'.$title.'"></td><td>'.$langs->trans("SetHereATitleForLink").'</td></tr>'; + print '<tr><td width="20%">'.$langs->trans("UrlOrLink").'</td><td><input class="flat" name="url" size="50" value=""></td><td>'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>'; + print '<tr><td width="20%">'.$langs->trans("BehaviourOnClick").'</td><td>'; + $liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow")); + $html->select_array('target',$liste,1); + print '</td><td>'.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'</td></tr>'; + print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("CreateBookmark").'"></td></tr>'; + print '</table>'; + + print '</form>'; +} + + +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 '<table class="border" width="100%">'; + + print '<tr><td width="20%">'.$langs->trans("BookmarkTitle").'</td><td>'.$bookmark->title.'</td></tr>'; + print '<tr><td width="20%">'.$langs->trans("UrlOrLink").'</td><td>'; + print '<a href="'.(eregi('^http',$bookmark->url)?$bookmark->url:DOL_URL_ROOT.$bookmark->url).'" target="'.($bookmark->target?"":"newlink").'">'.$bookmark->url.'</a></td></tr>'; + print '<tr><td width="20%">'.$langs->trans("BehaviourOnClick").'</td><td>'; + if ($bookmark->target == 0) print $langs->trans("OpenANewWindow"); + if ($bookmark->target == 1) print $langs->trans("ReplaceWindow"); + print '</td></tr>'; + print '</table>'; + + print "</div>\n"; + + print "<div class=\"tabsAction\">\n"; + + // Supprimer + if ($user->rights->bookmark->supprimer) + { + print " <a class=\"butActionDelete\" href=\"liste.php?bid=".$bookmark->id."&action=delete\">".$langs->trans("Delete")."</a>\n"; + } + + print '</div>'; + +} $db->close(); + llxFooter('$Date$ - $Revision$'); + ?> diff --git a/htdocs/bookmarks/liste.php b/htdocs/bookmarks/liste.php index 5fee4cb7a198059a0fa4deece4814d8208f441f1..ab0306e4fcadf871971092c53873b69881163776 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 "<tr class=\"liste_titre\">"; //print "<td> </td>"; print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"],"bid","","",'align="left"',$sortfield); - print "<td>".$langs->trans("Title")."</td>"; - print "<td>".$langs->trans("Link")."</td>"; + print '<td>'.$langs->trans("Title")."</td>"; + print '<td>'.$langs->trans("Link")."</td>"; + print '<td align="center">'.$langs->trans("Target")."</td>"; 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 "<td> </td>"; @@ -137,20 +139,34 @@ if ($resql) // Url print "<td>"; - if (! $lieninterne) print "<a href=\"".$obj->url."\">"; + if (! $lieninterne) print '<a href="'.$obj->url.'"'.($obj->target?' target="newlink"':'').'>'; print $lien; - if (! $lieninterne) print "</a>"; + if (! $lieninterne) print '</a>'; print "</td>\n"; - // Auteur - print "<td><a href='".DOL_URL_ROOT."/user/fiche.php?id=".$obj->fk_user."'>".img_object($langs->trans("ShowUser"),"user").' '.$obj->code."</a></td>\n"; + // Target + print '<td align="center">'; + if ($obj->target == 0) print $langs->trans("BookmarkTargetReplaceWindowShort"); + if ($obj->target == 1) print $langs->trans("BookmarkTargetNewWindowShort"); + print "</td>\n"; + // Auteur + print '<td align="center"><a href="'.DOL_URL_ROOT."/user/fiche.php?id=".$obj->fk_user."'>".img_object($langs->trans("ShowUser"),"user").' '.$obj->code."</a></td>\n"; + // Date creation print '<td align="center">'.dolibarr_print_date($obj->dateb) ."</td>"; // Actions - print "<td><a href=\"".$_SERVER["PHP_SELF"]."?action=delete&bid=$obj->bid\">".img_delete()."</a></td>\n"; - + print "<td>"; + if ($user->rights->bookmark->supprimer) + { + print "<a href=\"".$_SERVER["PHP_SELF"]."?action=delete&bid=$obj->bid\">".img_delete()."</a>"; + } + else + { + print " "; + } + print "</td>"; print "</tr>\n"; $i++; } diff --git a/htdocs/bookmarks/pre.inc.php b/htdocs/bookmarks/pre.inc.php index cb251141e56f3b2f05318ad4b8e80cb9831262d6..b56f8cecf76049ef2462bd93c89e2e6eee13d4af 100644 --- a/htdocs/bookmarks/pre.inc.php +++ b/htdocs/bookmarks/pre.inc.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * * 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 809a30ad3558f256c0ef66b872c58c529bb80abf..5862075339b31c3133b17f8cfb533081e39bec37 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 bbe51db2013f70bbda826fa7748c077930591c82..b3ad970f720c96148ec862a76da7fd93e91e4c0e 100644 --- a/htdocs/includes/modules/modBookmark.class.php +++ b/htdocs/includes/modules/modBookmark.class.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * * 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 81594db59195736eacbb4d77d5f6a68160ff60ee..d66e6b6faaf772103cb2795db0bc119b2784a225 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 624b5e7d8498b1d0ebc52d305ea37d01684d20fa..a034b69238aeb58fa2dc5212245ed3d6a606a489 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 101838e2a9aaad02be7734c9dd85b93952ed7c28..beb74e16dbcfc573f2449c6a209a516a3f25fed8 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 38bc817a4cc58a55fbaa025ee2dc9eec5e683e94..f07f89ee8911e7568aea9144791adde08a164a3f 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