Merge pull request #2325 from aaujon/3.6-webservices-contact
FIXED #1824 Add ref_ext for Contact webservices
This commit is contained in:
commit
6eb0d34032
@ -140,6 +140,7 @@ class Contact extends CommonObject
|
||||
$sql.= ", statut";
|
||||
$sql.= ", canvas";
|
||||
$sql.= ", entity";
|
||||
$sql.= ",ref_ext";
|
||||
$sql.= ", import_key";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->db->idate($now)."',";
|
||||
@ -152,6 +153,7 @@ class Contact extends CommonObject
|
||||
$sql.= " ".$this->statut.",";
|
||||
$sql.= " ".(! empty($this->canvas)?"'".$this->canvas."'":"null").",";
|
||||
$sql.= " ".$conf->entity.",";
|
||||
$sql.= "'".$this->db->escape($this->ref_ext)."',";
|
||||
$sql.= " ".(! empty($this->import_key)?"'".$this->import_key."'":"null");
|
||||
$sql.= ")";
|
||||
|
||||
@ -496,10 +498,12 @@ class Contact extends CommonObject
|
||||
*
|
||||
* @param int $id id du contact
|
||||
* @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact
|
||||
* @param string $ref_ext External reference, not given by Dolibarr
|
||||
* @return int -1 if KO, 0 if OK but not found, 1 if OK
|
||||
*/
|
||||
function fetch($id, $user=0)
|
||||
function fetch($id, $user=0, $ref_ext='')
|
||||
{
|
||||
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
|
||||
global $langs;
|
||||
|
||||
$langs->load("companies");
|
||||
@ -521,7 +525,8 @@ class Contact extends CommonObject
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
|
||||
$sql.= " WHERE c.rowid = ". $id;
|
||||
if ($id) $sql.= " WHERE c.rowid = ". $id;
|
||||
elseif ($ref_ext) $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
@ -83,6 +83,7 @@ $server->wsdl->addComplexType(
|
||||
|
||||
$contact_fields = array(
|
||||
'id' => array('name'=>'id','type'=>'xsd:string'),
|
||||
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
|
||||
'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
|
||||
'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
|
||||
'address' => array('name'=>'address','type'=>'xsd:string'),
|
||||
@ -176,14 +177,14 @@ $styleuse='encoded'; // encoded/literal/literal wrapped
|
||||
$server->register(
|
||||
'getContact',
|
||||
// Entry values
|
||||
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
|
||||
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref_ext'=>'xsd:string'),
|
||||
// Exit values
|
||||
array('result'=>'tns:result','contact'=>'tns:contact'),
|
||||
$ns,
|
||||
$ns.'#getContact',
|
||||
$styledoc,
|
||||
$styleuse,
|
||||
'WS to get contact'
|
||||
'WS to get a contact'
|
||||
);
|
||||
|
||||
// Register WSDL
|
||||
@ -232,16 +233,15 @@ $server->register(
|
||||
* Get Contact
|
||||
*
|
||||
* @param array $authentication Array of authentication information
|
||||
* @param int $id Id of object
|
||||
* @param string $ref Ref of object
|
||||
* @param ref_ext $ref_ext Ref external of object
|
||||
* @param int $id Id of object
|
||||
* @param string $ref_ext Ref external of object
|
||||
* @return mixed
|
||||
*/
|
||||
function getContact($authentication,$id,$ref='',$ref_ext='')
|
||||
function getContact($authentication,$id,$ref_ext)
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
|
||||
dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
|
||||
dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext);
|
||||
|
||||
if ($authentication['entity']) $conf->entity=$authentication['entity'];
|
||||
|
||||
@ -251,10 +251,10 @@ function getContact($authentication,$id,$ref='',$ref_ext='')
|
||||
$error=0;
|
||||
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
|
||||
// Check parameters
|
||||
if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
|
||||
if (! $error && ($id && $ref_ext))
|
||||
{
|
||||
$error++;
|
||||
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
|
||||
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be both provided. You must choose one or other but not both.";
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@ -262,7 +262,7 @@ function getContact($authentication,$id,$ref='',$ref_ext='')
|
||||
$fuser->getrights();
|
||||
|
||||
$contact=new Contact($db);
|
||||
$result=$contact->fetch($id,$ref,$ref_ext);
|
||||
$result=$contact->fetch($id,0,$ref_ext);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Only internal user who have contact read permission
|
||||
@ -273,6 +273,7 @@ function getContact($authentication,$id,$ref='',$ref_ext='')
|
||||
){
|
||||
$contact_result_fields =array(
|
||||
'id' => $contact->id,
|
||||
'ref_ext' => $contact->ref_ext,
|
||||
'lastname' => $contact->lastname,
|
||||
'firstname' => $contact->firstname,
|
||||
'address' => $contact->address,
|
||||
@ -383,6 +384,7 @@ function createContact($authentication,$contact)
|
||||
$newobject=new Contact($db);
|
||||
|
||||
$newobject->id=$contact['id'];
|
||||
$newobject->ref_ext=$contact['ref_ext'];
|
||||
$newobject->civility_id=$contact['civility_id'];
|
||||
$newobject->lastname=$contact['lastname'];
|
||||
$newobject->firstname=$contact['firstname'];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user