Fix: multicompany compatibility

This commit is contained in:
Regis Houssin 2012-03-29 01:39:56 +08:00
parent cb0fa0ad11
commit b204ad5b84
4 changed files with 23 additions and 16 deletions

View File

@ -523,22 +523,28 @@ class Categorie
/**
* Return list of contents of a category
*
* @param string $field Field name for select in table. Full field name will be fk_field.
* @param string $classname PHP Class of object to store entity
* @param string $table Table name for select in table. Full table name will be PREFIX_categorie_table.
* @param string $field Field name for select in table. Full field name will be fk_field.
* @param string $classname PHP Class of object to store entity
* @param string $category_table Table name for select in table. Full table name will be PREFIX_categorie_table.
* @param string $object_table Table name for select in table. Full table name will be PREFIX_table.
* @return void
*/
function get_type($field,$classname,$table='')
function get_type($field,$classname,$category_table='',$object_table='')
{
$objs = array();
// Clean parameters
if (empty($table)) $table=$field;
if (empty($category_table)) $category_table=$field;
if (empty($object_table)) $object_table=$field;
$sql = "SELECT fk_".$field." FROM ".MAIN_DB_PREFIX."categorie_".$table;
$sql.= " WHERE fk_categorie = ".$this->id;
$sql = "SELECT c.fk_".$field;
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$category_table." as c";
$sql.= ", ".MAIN_DB_PREFIX.$object_table." as o";
$sql.= " WHERE c.fk_categorie = ".$this->id;
$sql.= " AND c.fk_".$field." = o.rowid";
$sql.= " AND o.entity IN (".getEntity($field, 1).")";
dol_syslog("Categorie::get_type sql=".$sql);
dol_syslog(get_class($this)."::get_type sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@ -553,7 +559,7 @@ class Categorie
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog("Categorie::get_type ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::get_type ".$this->error, LOG_ERR);
return -1;
}
}

View File

@ -322,7 +322,7 @@ if ($object->type == 3)
{
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
$prods = $object->get_type("member","Adherent");
$prods = $object->get_type("member","Adherent","","adherent");
if ($prods < 0)
{
dol_print_error($db,$object->error);
@ -358,7 +358,7 @@ if ($object->type == 3)
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 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
@ -32,9 +33,9 @@ $langs->load("other");
if ($conf->notification->enabled) $langs->load("mails");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe','','');
$result = restrictedArea($user, 'societe', $socid, '&societe');
/*

View File

@ -66,7 +66,7 @@ if (! empty($canvas))
}
// Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', '', '', $objcanvas);
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');