Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into 6.0

This commit is contained in:
Laurent Destailleur 2017-07-25 13:31:54 +02:00
commit 0d5cd5d970

View File

@ -334,23 +334,23 @@ abstract class CommonObject
// No constructor as it is an abstract class // No constructor as it is an abstract class
/** /**
* Check an object id/ref exists * Check an object id/ref exists
* If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch * If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch
* *
* @param string $element String of element ('product', 'facture', ...) * @param string $element String of element ('product', 'facture', ...)
* @param int $id Id of object * @param int $id Id of object
* @param string $ref Ref of object to check * @param string $ref Ref of object to check
* @param string $ref_ext Ref ext of object to check * @param string $ref_ext Ref ext of object to check
* @return int <0 if KO, 0 if OK but not found, >0 if OK and exists * @return int <0 if KO, 0 if OK but not found, >0 if OK and exists
*/ */
static function isExistingObject($element, $id, $ref='', $ref_ext='') static function isExistingObject($element, $id, $ref='', $ref_ext='')
{ {
global $db,$conf; global $db,$conf;
$sql = "SELECT rowid, ref, ref_ext"; $sql = "SELECT rowid, ref, ref_ext";
$sql.= " FROM ".MAIN_DB_PREFIX.$element; $sql.= " FROM ".MAIN_DB_PREFIX.$element;
$sql.= " WHERE entity IN (".getEntity($element, true).")" ; $sql.= " WHERE entity IN (".getEntity($element).")" ;
if ($id > 0) $sql.= " AND rowid = ".$db->escape($id); if ($id > 0) $sql.= " AND rowid = ".$db->escape($id);
else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'"; else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'";
@ -371,17 +371,17 @@ abstract class CommonObject
else return 0; else return 0;
} }
return -1; return -1;
} }
/** /**
* Method to output saved errors * Method to output saved errors
* *
* @return string String with errors * @return string String with errors
*/ */
function errorsToString() function errorsToString()
{ {
return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):''); return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):'');
} }
/** /**
* Return full name (civility+' '+name+' '+lastname) * Return full name (civility+' '+name+' '+lastname)