Skip to content

Commit

Permalink
Support bookmark add of product cards
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 4, 2008
1 parent 33ad422 commit 31eaa7c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 49 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
@@ -1,5 +1,18 @@
English Dolibarr changelog

***** Changelog for 2.5 compared to 2.4 *****

For users:
- Support bookmark add of product cards.
- New view in ecm module.

For translators:
- The errors language file contains only error or warning messages with
prefix Error or Warning.

For developers:
- Update skeletons.


***** Changelog for 2.4 compared to 2.2 *****

Expand Down
41 changes: 26 additions & 15 deletions htdocs/bookmarks/fiche.php
Expand Up @@ -40,31 +40,45 @@
* Actions
*/

if ($action == 'add')
if ($action == 'add' || $action == 'addproduct')
{
$mesg='';

$bookmark=new Bookmark($db);
$bookmark->fk_user=$user->id;
if ($_GET["socid"]) // Lien vers fiche comm société
$bookmark->title=$title;
$bookmark->url=$url;
$bookmark->target=$target;

if ($action == 'add' && $_GET["socid"]) // Link to third party card
{
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
$langs->load("companies");
$societe=new Societe($db);
$societe->fetch($_GET["socid"]);
$bookmark->fk_soc=$societe->id;
$bookmark->url=DOL_URL_ROOT.'/soc.php?socid='.$societe->id;
$bookmark->target='0';
$bookmark->title=$societe->nom;
$bookmark->title=$langs->trans("ThirdParty").' '.$societe->nom;
//$bookmark->title=$societe->nom;
$title=$bookmark->title;
$url=$bookmark->url;
}
else
if ($action == 'addproduct' && $_GET["id"]) // Link to product card
{
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;
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langs->load("products");
$product=new Product($db);
$product->fetch($_GET["id"]);
$bookmark->url=DOL_URL_ROOT.'/product/fiche.php?id='.$product->id;
$bookmark->target='0';
$bookmark->title=($product->type != 1 ?$langs->trans("Product"):$langs->trans("Service")).' '.$product->ref;
//$bookmark->title=$product->ref;
$title=$bookmark->title;
$url=$bookmark->url;
}

if (! $title) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle"));
if (! $url) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink"));

if (! $mesg)
{
Expand All @@ -89,8 +103,6 @@
$mesg='<div class="error">'.$bookmark->error.'</div>';
}
$action='create';
$title=$bookmark->title;
$url=$bookmark->url;
}
}
else
Expand Down Expand Up @@ -160,7 +172,7 @@
}


if ($_GET["id"] > 0)
if ($_GET["id"] > 0 && ! eregi('^add',$_GET["action"]))
{
/*
* Fiche bookmark en mode edition
Expand Down Expand Up @@ -200,5 +212,4 @@


llxFooter('$Date$ - $Revision$');

?>
26 changes: 12 additions & 14 deletions htdocs/bookmarks/liste.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2005-2008 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
Expand All @@ -14,18 +14,15 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/

/**
\file htdocs/bookmarks/liste.php
\brief Page affichage des bookmarks
\ingroup bookmark
\version $Revision$
*/
* \file htdocs/bookmarks/liste.php
* \brief Page affichage des bookmarks
* \ingroup bookmark
* \version $Id$
*/

require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/bookmarks/bookmark.class.php");

Expand Down Expand Up @@ -54,6 +51,7 @@
if ($res > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
Expand All @@ -63,7 +61,7 @@


/*
* Affichage liste
* View
*/

llxHeader();
Expand Down Expand Up @@ -124,7 +122,7 @@
$lien="Dolibarr";
if (! $obj->title)
{
// Pour compatibilite avec anciens bookmarks
// For compatibility with old Dolibarr bookmarks
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
$societe=new Societe($db);
$societe->fetch($obj->rowid);
Expand All @@ -150,11 +148,11 @@
if ($obj->target == 1) print $langs->trans("BookmarkTargetNewWindowShort");
print "</td>\n";

// Auteur
// Author
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->fk_user.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login."</a></td>\n";

// Date creation
print '<td align="center">'.dolibarr_print_date($obj->dateb) ."</td>";
print '<td align="center">'.dolibarr_print_date($obj->dateb,'day') ."</td>";

// Actions
print "<td>";
Expand Down
7 changes: 4 additions & 3 deletions htdocs/langs/en_US/errors.lang
Expand Up @@ -18,7 +18,7 @@ ErrorSupplierCodeAlreadyUsed=Supplier code already used
ErrorBadParameters=Bad parameters
ErrorFailedToWriteInDir=Failed to write in directory %s
ErrorFoundBadEmailInFile=Found incorrect email syntax for %s lines in file (example line %s with email=%s)
UserCannotBeDelete=User can not be deleted. May be it is associated on Dolibarr entities.
ErrorUserCannotBeDelete=User can not be deleted. May be it is associated on Dolibarr entities.
ErrorFieldsRequired=Some required fields were not filled.
ErrorFailedToCreateDir=Failed to create a directory. Check that Web server user has permissions to write into Dolibarr documents directory. If parameter <b>safe_mode</b> is enabled on this PHP, check that Dolibarr php files owns to web server user (or group).
ErrorNoMailDefinedForThisUser=No mail defined for this user
Expand All @@ -28,6 +28,7 @@ ErrorLeftMenuMustHaveAParentId=A menu of type 'Left' must have a parent id.
ErrorGenbarCodeNotfound=File not found (Bad path, wrong permissions or access denied by openbasedir parameter)
ErrorFunctionNotAvailableInPHP=Function <b>%s</b> is required for this feature but is not available in this version/setup of PHP.
ErrorDirAlreadyExists=A directory with this name already exists.
WarningAllowUrlFopenMustBeOn=Parameter <b>allow_url_fopen</b> must be set to <b>on</b> in filer <b>php.ini</b> for having this module working completely. You must modify this file manually.
ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters.
WarningBuildScriptNotRunned=Script <b>%s</b> was not yet ran to build graphics.
WarningAllowUrlFopenMustBeOn=Parameter <b>allow_url_fopen</b> must be set to <b>on</b> in filer <b>php.ini</b> for having this module working completely. You must modify this file manually.
WarningBuildScriptNotRunned=Script <b>%s</b> was not yet ran to build graphics.
WarningBookmarkAlreadyExists=A bookmark with this title or this target (URL) already exists.
4 changes: 1 addition & 3 deletions htdocs/langs/es_ES/errors.lang
@@ -1,6 +1,4 @@
# Dolibarr language file - es_ES - errors


ErrorDuplicateTrigger=Un archvio trigger de nombre '<b>%s</b>' est� cargado. Elimine el dobre de la carpeta '<b>%s</b>'.
ErrorFailToDeleteFile=Error al eliminar el archivo '<b>%s</b>'.
ErrorThisContactIsAlreadyDefinedAsThisType=Este contacto ya est� definido como contacto para este tipo.
Expand All @@ -16,7 +14,7 @@ ErrorSupplierCodeRequired=C
ErrorSupplierCodeAlreadyUsed=C�digo de proveedor ya utilizado
ErrorBadParameters=Par�metros incorrectos
ErrorFailedToWriteInDir=Imposible escribir en la carpeta %s
UserCannotBeDelete=El usuario no puede ser eliminado. Quiz� es� asociado a elementos de Dolibarr.
ErrorUserCannotBeDelete=El usuario no puede ser eliminado. Quiz� es� asociado a elementos de Dolibarr.
ErrorFieldsRequired=No se indicaron algunos campos obligatorios
ErrorFailedToCreateDir=Error en la creaci�n de una carpeta. Compruebe que el usuario del servidor Web tiene derechos de escritura en las carpetas de documentos de Dolibarr. Si el par�metro <b>safe_mode</b> est� activo en este PHP, Compruebe que los archivos php dolibarr pertenecen al usuario del servidor Web.
ErrorNoMailDefinedForThisUser=E-Mail no definido para este usuario
Expand Down
7 changes: 4 additions & 3 deletions htdocs/langs/fr_FR/errors.lang
Expand Up @@ -18,7 +18,7 @@ ErrorSupplierCodeAlreadyUsed=Code fournisseur deja utilise
ErrorBadParameters=Parametres incorrects
ErrorFailedToWriteInDir=Impossible d'�crire dans le r�pertoire %s
ErrorFoundBadEmailInFile=Syntaxe de mail incorrecte trouv�e pour %s lignes dans le fichier (exemple line %s avec email=%s)
UserCannotBeDelete=L'utilisateur ne peut pas etre supprim�e. Peut-�tre est-il associ� � des �l�ments de Dolibarr.
ErrorUserCannotBeDelete=L'utilisateur ne peut pas etre supprim�e. Peut-�tre est-il associ� � des �l�ments de Dolibarr.
ErrorFieldsRequired=Des champs obligatoires n'ont pas �t� renseign�s
ErrorFailedToCreateDir=Echec a la creation d'un repertoire. Verifiez que le user du serveur Web a bien les droits d'ecriture dans les repertoires documents de Dolibarr. Si le parametre <b>safe_mode</b> a �t� activ� sur ce PHP, v�rifier que les fichiers php dolibarr appartiennent � l'utilisateur du serveur Web.
ErrorNoMailDefinedForThisUser=EMail non defini pour cet utilisateur
Expand All @@ -28,6 +28,7 @@ ErrorLeftMenuMustHaveAParentId=Un menu de type 'Left' doit avoir un id de p
ErrorGenbarCodeNotfound=Fichier introuvable (Mauvais chemin, permissions incorrectes ou acc�s interdit par le param�tre openbasedir)
ErrorFunctionNotAvailableInPHP=La fonction <b>%s</b> est requise pour cette fonctionnalit� mais n'est pas disponible dans cette version/installation de PHP.
ErrorDirAlreadyExists=Un r�pertoire portant ce nom existe d�j�.
WarningAllowUrlFopenMustBeOn=Attention, le param�tre <b>allow_url_fopen</b> doit etre positionn� � <b>on</b> dans le fichier <b>php.ini</b> pour que ce module soit pleinement op�rationnel. Vous devez modifier ce fichier manuellement.
ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caract�res sp�ciaux.
WarningBuildScriptNotRunned=Le script <b>%s</b> n'a pas encore �t� lanc� pour g�n�rer les graphiques.
WarningAllowUrlFopenMustBeOn=Attention, le param�tre <b>allow_url_fopen</b> doit etre positionn� � <b>on</b> dans le fichier <b>php.ini</b> pour que ce module soit pleinement op�rationnel. Vous devez modifier ce fichier manuellement.
WarningBuildScriptNotRunned=Le script <b>%s</b> n'a pas encore �t� lanc� pour g�n�rer les graphiques.
WarningBookmarkAlreadyExists=Un marque-page avec ce titre ou cette destination (URL) existe d�j�.
28 changes: 18 additions & 10 deletions htdocs/lib/product.lib.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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
Expand All @@ -19,9 +19,9 @@
*/

/**
\file htdocs/lib/product.lib.php
\brief Ensemble de fonctions de base pour le module produit et service
\version $Id$
* \file htdocs/lib/product.lib.php
* \brief Ensemble de fonctions de base pour le module produit et service
* \version $Id$
*/

function product_prepare_head($product, $user)
Expand All @@ -45,7 +45,7 @@ function product_prepare_head($product, $user)
$head[$h][2] = 'photos';
$h++;

//affichage onglet cat�gorie
// Show category tab
if ($conf->categorie->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$product->id;
Expand All @@ -54,7 +54,7 @@ function product_prepare_head($product, $user)
$h++;
}

// Affichage onglet code barre
// Show barcode tab
if ($conf->global->MAIN_MODULE_BARCODE)
{
$head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
Expand All @@ -72,7 +72,7 @@ function product_prepare_head($product, $user)
$h++;
}

// sousproduits
// Sub products
if($conf->global->PRODUIT_SOUSPRODUITS == 1)
{
$head[$h][0] = DOL_URL_ROOT."/product/sousproduits/fiche.php?id=".$product->id;
Expand Down Expand Up @@ -122,11 +122,19 @@ function product_prepare_head($product, $user)
{
foreach ($product->onglets as $onglet)
{
$head[$h] = $onglet;
$h++;
$head[$h] = $onglet;
$h++;
}
}

if ($conf->bookmark->enabled && $user->rights->bookmark->creer)
{
$head[$h][0] = DOL_URL_ROOT."/bookmarks/fiche.php?action=addproduct&amp;id=".$product->id."&amp;urlsource=".$_SERVER["PHP_SELF"]."?id=".$product->id;
$head[$h][1] = img_object($langs->trans("BookmarkThisPage"),'bookmark');
$head[$h][2] = 'image';
$h++;
}

return $head;
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/fiche.php
Expand Up @@ -115,7 +115,7 @@
if ($result < 0)
{
$langs->load("errors");
$message='<div class="error">'.$langs->trans("UserCannotBeDelete").'</div>';
$message='<div class="error">'.$langs->trans("ErrorUserCannotBeDelete").'</div>';
}
else
{
Expand Down

0 comments on commit 31eaa7c

Please sign in to comment.