diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 02ac9c26e67..394a2c60810 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005 Davoleau Brice * Copyright (C) 2005 Rodolphe Quiedeville - * Copyright (C) 2006-2008 Regis Houssin + * Copyright (C) 2006-2011 Regis Houssin * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * @@ -24,7 +24,7 @@ * \file htdocs/categories/class/categorie.class.php * \ingroup categorie * \brief File of class to manage categories - * \version $Id: categorie.class.php,v 1.18 2011/08/03 00:46:39 eldy Exp $ + * \version $Id: categorie.class.php,v 1.19 2011/08/20 09:02:56 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); @@ -147,7 +147,8 @@ class Categorie $sql.= "fk_soc,"; } $sql.= " visible,"; - $sql.= " type"; + $sql.= " type,"; + $sql.= " entity"; //$sql.= ", fk_parent_id"; $sql.= ")"; $sql.= " VALUES ('".$this->db->escape($this->label)."', '".$this->db->escape($this->description)."',"; @@ -155,7 +156,7 @@ class Categorie { $sql.= ($this->socid != -1 ? $this->socid : 'null').","; } - $sql.= "'".$this->visible."',".$this->type; + $sql.= "'".$this->visible."',".$this->type.",".$conf->entity; //$sql.= ",".$this->parentId; $sql.= ")"; @@ -609,11 +610,16 @@ class Categorie */ function get_full_arbo($type,$markafterid=0) { + global $conf; + $this->cats = array(); // Charge tableau des meres - $sql = "SELECT fk_categorie_mere as id_mere, fk_categorie_fille as id_fille"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + $sql = "SELECT ca.fk_categorie_mere as id_mere, ca.fk_categorie_fille as id_fille"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association ca"; + $sql.= ", ".MAIN_DB_PREFIX."categorie as c"; + $sql.= " WHERE ca.fk_categorie_mere = c.rowid"; + $sql.= " AND c.entity = ".$conf->entity; // Load array this->motherof dol_syslog("Categorie::get_full_arbo build motherof array sql=".$sql, LOG_DEBUG); @@ -635,8 +641,9 @@ class Categorie $sql = "SELECT DISTINCT c.rowid, c.label as label, ca.fk_categorie_fille as rowid_fille"; // Distinct reduce pb with old tables with duplicates $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_association as ca"; - $sql.= " ON c.rowid=ca.fk_categorie_mere"; + $sql.= " ON c.rowid = ca.fk_categorie_mere"; $sql.= " WHERE c.type = ".$type; + $sql.= " AND c.entity = ".$conf->entity; $sql.= " ORDER BY c.label, c.rowid"; dol_syslog("Categorie::get_full_arbo get category list sql=".$sql, LOG_DEBUG); diff --git a/htdocs/categories/docreate.php b/htdocs/categories/docreate.php deleted file mode 100644 index c858d2c0f11..00000000000 --- a/htdocs/categories/docreate.php +++ /dev/null @@ -1,83 +0,0 @@ - - * Copyright (C) 2006 Regis Houssin - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Id: docreate.php,v 1.9 2011/08/03 00:46:32 eldy Exp $ - */ - -/** - * \file htdocs/categories/docreate.php - * \ingroup category - * \brief Page de creation categorie - * \version $Revision: 1.9 $ - */ - -require("../main.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); - -$langs->load("categories"); - - -if (!isset($_REQUEST["nom"]) || !isset($_REQUEST["description"])) - accessforbidden(); - - -/** - * Affichage page accueil - */ - -llxHeader("","",$langs->trans("Categories")); - -print_titre($langs->trans("CatCreated")); - -print ''; - -print '
'; - -$categorie = new Categorie($db); - -$categorie->label = $_REQUEST["nom"]; -$categorie->description = $_REQUEST["description"]; - -$cats_meres = isset($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array(); - -$res = $categorie->create(); - - if ($res < 0) - { - print "

Impossible d'ajouter la cat�gorie ".$categorie->label.".

"; - } - else - { - print "

La cat�gorie ".$categorie->label." a �t� ajout�e avec succ�s.

"; - - foreach ($cats_meres as $id) - { - $mere = new Categorie($db, $id); - $res = $mere->add_fille($categorie); - - if ($res < 0) - { - print "

Impossible d'associer la cat�gorie � \"".$mere->label."\" ($res).

"; - } - } - } - - -print '
'; - -$db->close(); -?> diff --git a/htdocs/categories/domodif.php b/htdocs/categories/domodif.php deleted file mode 100644 index b918b177d91..00000000000 --- a/htdocs/categories/domodif.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - \file htdocs/categories/domodif.php - \ingroup category - \brief Page de modification categorie - \version $Revision: 1.6 $ -*/ - -require("../main.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); - -if (!isset ($_REQUEST["id"]) || !isset ($_REQUEST["nom"]) || !isset ($_REQUEST["description"])) - accessforbidden(); - - -/** - * Affichage page accueil - */ - -llxHeader("","",$langs->trans("Categories")); - -print_titre($langs->trans("CatCreated")); - -print ''; - -print '
'; - -$cat = new Categorie ($db, $_REQUEST['id']); - -$cat->label = $_REQUEST["nom"]; -$cat->description = $_REQUEST["description"]; - -$new_cats_meres = isset ($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array (); -// tableau d'id de categories - -$old_objs_meres = $cat->get_meres (); -// tableau d'objets categorie - -$old_cats_meres = array (); -foreach ($old_objs_meres as $old_obj_mere) -{ // transformation en tableau d'id - $old_cats_meres[] = $old_obj_mere->id; -} - -$asupprimer = array (); // tableaux des categories meres -$aajouter = array (); // a ajouter ou a supprimer - -foreach ($old_cats_meres as $old_cat) -{ - if (!in_array ($old_cat, $new_cats_meres)) - { - $asupprimer[] = new Categorie ($db, $old_cat); - } -} - -foreach ($new_cats_meres as $new_cat) -{ - if (!in_array ($new_cat, $old_cats_meres)) - { - $aajouter[] = new Categorie ($db, $new_cat); - } -} - -$res = $cat->update (); -if ($res < 0) -{ - print "

Impossible de modifier la categorie ".$cat->label.".

"; -} -else -{ - print "

La categorie ".$cat->label." a ete modifiee avec succes.

"; - - foreach ($asupprimer as $old_mere) - { - $res = $old_mere->del_fille ($cat); - if ($res < 0) - { - print "

Impossible d'enlever la categorie de \"".$old_mere->label."\" ($res).

\n"; - } - else - { - print "

La categorie ne fait plus partie de ".$old_mere->label.".

\n"; - } - } - - foreach ($aajouter as $new_mere) - { - $res = $new_mere->add_fille ($cat); - if ($res < 0) - { - print "

Impossible d'ajouter la categorie a \"".$new_mere->label."\" ($res).

"; - } - else - { - print "

La categorie fait maintenant partie de ".$new_mere->label.".

\n"; - } - } -} - -print '
'; - -$db->close(); -?> diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index b09bbaafdb5..389d333a47c 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -1,7 +1,7 @@ * Copyright (C) 2006-2010 Laurent Destailleur - * Copyright (C) 2005-2008 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2007 Patrick Raguin * * This program is free software; you can redistribute it and/or modify @@ -22,18 +22,28 @@ * \file htdocs/categories/edit.php * \ingroup category * \brief Page d'edition de categorie produit - * \version $Id: edit.php,v 1.39 2011/08/03 00:46:31 eldy Exp $ + * \version $Id: edit.php,v 1.40 2011/08/20 09:02:57 hregis Exp $ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); -// Security check -if (!$user->rights->categorie->lire) - accessforbidden(); +$id=GETPOST('id'); +$ref=GETPOST('ref'); +$type=GETPOST('type'); +$action=GETPOST('action'); +$confirm=GETPOST('confirm'); + +if ($id == "") +{ + dol_print_error('','Missing parameter id'); + exit(); +} + +// Security check +$result = restrictedArea($user, 'categorie', $id); -$type=$_REQUEST['type']; /* @@ -41,10 +51,10 @@ $type=$_REQUEST['type']; */ // Action mise a jour d'une categorie -if ($_POST["action"] == 'update' && $user->rights->categorie->creer) +if ($action == 'update' && $user->rights->categorie->creer) { $categorie = new Categorie ($db); - $result=$categorie->fetch($_REQUEST['id']); + $result=$categorie->fetch($id); $categorie->label = $_POST["nom"]; $categorie->description = $_POST["description"]; @@ -103,7 +113,7 @@ if ($mesg) print ''; } -$categorie = new Categorie ($db, $_REQUEST['id']); +$categorie = new Categorie ($db, $id); $html = new Form($db); print ''; @@ -151,5 +161,5 @@ print '
'; $db->close(); -llxFooter('$Date: 2011/08/03 00:46:31 $ - $Revision: 1.39 $'); +llxFooter('$Date: 2011/08/20 09:02:57 $ - $Revision: 1.40 $'); ?> diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index f3279023102..b4fbed586bd 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * * 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 @@ -23,7 +23,7 @@ * \file htdocs/categories/index.php * \ingroup category * \brief Home page of category area - * \version $Id: index.php,v 1.55 2011/08/03 00:46:32 eldy Exp $ + * \version $Id: index.php,v 1.56 2011/08/20 09:02:57 hregis Exp $ */ require("../main.inc.php"); @@ -312,5 +312,5 @@ print ""; $db->close(); -llxFooter('$Date: 2011/08/03 00:46:32 $ - $Revision: 1.55 $'); +llxFooter('$Date: 2011/08/20 09:02:57 $ - $Revision: 1.56 $'); ?> diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 6e177d531b1..87bf59014d1 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * * 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 @@ -22,7 +22,7 @@ * \file htdocs/categories/photos.php * \ingroup category * \brief Gestion des photos d'une categorie - * \version $Id: photos.php,v 1.14 2011/08/17 15:56:26 eldy Exp $ + * \version $Id: photos.php,v 1.15 2011/08/20 09:02:57 hregis Exp $ */ require("../main.inc.php"); @@ -33,8 +33,6 @@ require_once(DOL_DOCUMENT_ROOT."/lib/categories.lib.php"); $langs->load("categories"); $langs->load("bills"); -// Security check -if (!$user->rights->categorie->lire) accessforbidden(); $mesg = ''; @@ -50,6 +48,9 @@ if ($id == "") exit(); } +// Security check +$result = restrictedArea($user, 'categorie', $id); + $object = new Categorie($db); /* @@ -304,5 +305,5 @@ else $db->close(); -llxFooter('$Date: 2011/08/17 15:56:26 $ - $Revision: 1.14 $'); +llxFooter('$Date: 2011/08/20 09:02:57 $ - $Revision: 1.15 $'); ?> diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5d426394b4f..f68a12f3d21 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2006-2010 Laurent Destailleur - * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2005-2011 Regis Houssin * * 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 @@ -22,7 +22,7 @@ * \file htdocs/categories/viewcat.php * \ingroup category * \brief Page to show a category card - * \version $Revision: 1.53 $ + * \version $Id: viewcat.php,v 1.54 2011/08/20 09:02:58 hregis Exp $ */ require("../main.inc.php"); @@ -31,11 +31,6 @@ require_once(DOL_DOCUMENT_ROOT."/lib/categories.lib.php"); $langs->load("categories"); -// Security check -if (! $user->rights->categorie->lire) accessforbidden(); - -$mesg = ''; - $mesg = ''; $id=GETPOST('id'); $ref=GETPOST('ref'); @@ -49,6 +44,9 @@ if ($id == "") exit(); } +// Security check +$result = restrictedArea($user, 'categorie', $id); + $object = new Categorie($db); $result=$object->fetch($id); if ($result <= 0) @@ -363,5 +361,5 @@ if ($object->type == 3) $db->close(); -llxFooter('$Date: 2011/08/03 00:46:31 $ - $Revision: 1.53 $'); +llxFooter('$Date: 2011/08/20 09:02:58 $ - $Revision: 1.54 $'); ?> \ No newline at end of file