Skip to content

Commit

Permalink
Merge pull request #2878 from atm-alexis/fix_multientity_num_check
Browse files Browse the repository at this point in the history
FIX when multicompany was enabled, isExistingObject check wrong
  • Loading branch information
eldy committed May 29, 2015
2 parents a33809a + 148c36c commit 4324ed8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -65,13 +65,15 @@ abstract class CommonObject
*/
static function isExistingObject($element, $id, $ref='', $ref_ext='')
{
global $db;
global $db,$conf;

$sql = "SELECT rowid, ref, ref_ext";
$sql.= " FROM ".MAIN_DB_PREFIX.$element;
if ($id > 0) $sql.= " WHERE rowid = ".$db->escape($id);
else if ($ref) $sql.= " WHERE ref = '".$db->escape($ref)."'";
else if ($ref_ext) $sql.= " WHERE ref_ext = '".$db->escape($ref_ext)."'";
$sql.= " WHERE entity IN (".getEntity($element).")" ;

if ($id > 0) $sql.= " AND rowid = ".$db->escape($id);
else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'";
else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'";
else {
$error='ErrorWrongParameters';
dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR);
Expand Down

0 comments on commit 4324ed8

Please sign in to comment.