From 2bea3ee5ccd142a34f9f040689f2220b71078d72 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Apr 2011 15:54:13 +0000 Subject: [PATCH] New: works on sharings between entities Fix: we check if all dependencies are ok --- htdocs/admin/boxes.php | 77 +++++++++++-------- htdocs/includes/boxes/box_contracts.php | 2 +- htdocs/includes/boxes/box_produits.php | 6 +- htdocs/includes/boxes/box_services_vendus.php | 4 +- htdocs/product/class/product.class.php | 8 +- 5 files changed, 55 insertions(+), 42 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 25345ddf76c..87a735c6c45 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2004-2011 Laurent Destailleur + * 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 @@ -289,43 +289,56 @@ if ($resql) dol_include_once($sourcefile); $box=new $boxname($db,$obj->note); - -// if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1) - if (in_array($obj->rowid, $actives)) + + $enabled=true; + if ($box->depends && sizeof($box->depends) > 0) { - // La boite est deja activee - } - else - { - $var = ! $var; - - if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg)) + foreach($box->depends as $module) { - $logo = $box->boximg; + if (empty($conf->$module->enabled)) $enabled=false; + } + } + + if ($enabled) + { + //if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1) + if (in_array($obj->rowid, $actives)) + { + // La boite est deja activee } else { - $logo=preg_replace("/^object_/i","",$box->boximg); + $var=!$var; + + if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg)) + { + $logo = $box->boximg; + } + else + { + $logo=preg_replace("/^object_/i","",$box->boximg); + } + + print '
'; + print ''; + print ''; + print ''.img_object("",$logo).' '.$box->boxlabel.''; + print '' . ($obj->note?$obj->note:' ') . ''; + print '' . $sourcefile . ''; + + // Pour chaque position possible, on affiche un lien + // d'activation si boite non deja active pour cette position + print ''; + print $html->selectarray("pos",$pos_name); + print ''; + print ''; + print ' '; + print ''; + + print '
'; } - - print '
'; - print ''; - print ''; - print ''.img_object("",$logo).' '.$box->boxlabel.''; - print '' . ($obj->note?$obj->note:' ') . ''; - print '' . $sourcefile . ''; - - // Pour chaque position possible, on affiche un lien - // d'activation si boite non deja active pour cette position - print ''; - print $html->selectarray("pos",$pos_name); - print ''; - print ''; - print ' '; - print ''; - - print '
'; } + $i++; } diff --git a/htdocs/includes/boxes/box_contracts.php b/htdocs/includes/boxes/box_contracts.php index 4e0efc39c82..ccb14f2faa5 100644 --- a/htdocs/includes/boxes/box_contracts.php +++ b/htdocs/includes/boxes/box_contracts.php @@ -31,7 +31,7 @@ class box_contracts extends ModeleBoxes { var $boxcode="lastcontracts"; var $boximg="object_contract"; var $boxlabel; - var $depends = array("contrat"); // conf->propal->enabled + var $depends = array("contrat"); // conf->contrat->enabled var $db; var $param; diff --git a/htdocs/includes/boxes/box_produits.php b/htdocs/includes/boxes/box_produits.php index ed1c2163b98..24578ddb36a 100644 --- a/htdocs/includes/boxes/box_produits.php +++ b/htdocs/includes/boxes/box_produits.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2004-2011 Laurent Destailleur + * 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 @@ -73,7 +73,7 @@ class box_produits extends ModeleBoxes { { $sql = "SELECT p.rowid, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= ' WHERE p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')'; if (!$user->rights->produit->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)'; if (!$user->rights->service->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)'; if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; diff --git a/htdocs/includes/boxes/box_services_vendus.php b/htdocs/includes/boxes/box_services_vendus.php index eefa339357a..4c02aef332d 100644 --- a/htdocs/includes/boxes/box_services_vendus.php +++ b/htdocs/includes/boxes/box_services_vendus.php @@ -1,7 +1,7 @@ - * Copyright (C) 2005-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Laurent Destailleur + * 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 diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 05f10c6c160..98571a987ea 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Jean Heimburger - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2011 Juanjo Menent * * 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 @@ -2746,7 +2746,7 @@ class Product extends CommonObject $sql.= " WHERE p.fk_product_type <> 1"; if (!$user->rights->produit->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)'; if (!$user->rights->service->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)'; - $sql.= " AND p.entity = ".$conf->entity; + $sql.= ' AND p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')'; $resql=$this->db->query($sql); if ($resql)