New: works on sharings between entities

Fix: we check if all dependencies are ok
This commit is contained in:
Regis Houssin 2011-04-18 15:54:13 +00:00
parent 15fe7b5bd8
commit 2bea3ee5cc
5 changed files with 55 additions and 42 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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 '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bc[$var].'>';
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
print '<td>' . ($obj->note?$obj->note:'&nbsp;') . '</td>';
print '<td>' . $sourcefile . '</td>';
// Pour chaque position possible, on affiche un lien
// d'activation si boite non deja active pour cette position
print '<td>';
print $html->selectarray("pos",$pos_name);
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="boxid" value="'.$obj->rowid.'">';
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
print '</td>';
print '</tr></form>';
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bc[$var].'>';
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
print '<td>' . ($obj->note?$obj->note:'&nbsp;') . '</td>';
print '<td>' . $sourcefile . '</td>';
// Pour chaque position possible, on affiche un lien
// d'activation si boite non deja active pour cette position
print '<td>';
print $html->selectarray("pos",$pos_name);
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="boxid" value="'.$obj->rowid.'">';
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
print '</td>';
print '</tr></form>';
}
$i++;
}

View File

@ -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;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2007 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
*
* 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)