Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
1aee361ffd
@ -171,6 +171,7 @@ abstract class CommonDocGenerator
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
$extrafields = new ExtraFields($this->db);
|
$extrafields = new ExtraFields($this->db);
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label('company',true);
|
$extralabels = $extrafields->fetch_name_optionals_label('company',true);
|
||||||
|
$object->fetch_optionals($object->id,$extralabels);
|
||||||
|
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
{
|
{
|
||||||
@ -178,9 +179,13 @@ abstract class CommonDocGenerator
|
|||||||
{
|
{
|
||||||
$object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency);
|
$object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency);
|
||||||
}
|
}
|
||||||
|
else if($extrafields->attribute_type[$key] == 'select')
|
||||||
|
{
|
||||||
|
$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]];
|
||||||
|
}
|
||||||
$array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key]));
|
$array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $array_thirdparty;
|
return $array_thirdparty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1217,11 +1217,12 @@ function dol_uncompress($inputfile,$outputdir)
|
|||||||
* @param string $dir Directory to scan
|
* @param string $dir Directory to scan
|
||||||
* @param string $regexfilter Regexfilter
|
* @param string $regexfilter Regexfilter
|
||||||
* @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.'))
|
* @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.'))
|
||||||
* @return strnig Full path to most recent file
|
* @param int $nohook Disable all hooks
|
||||||
|
* @return string Full path to most recent file
|
||||||
*/
|
*/
|
||||||
function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('\.meta$','^\.'))
|
function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('\.meta$','^\.'),$nohook=false)
|
||||||
{
|
{
|
||||||
$tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC);
|
$tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,'',$nohook);
|
||||||
return $tmparray[0];
|
return $tmparray[0];
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -211,7 +211,19 @@ $server->register(
|
|||||||
'WS to get all contacts of a third party'
|
'WS to get all contacts of a third party'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Register WSDL
|
||||||
|
$server->register(
|
||||||
|
'updateContact',
|
||||||
|
// Entry values
|
||||||
|
array('authentication'=>'tns:authentication','contact'=>'tns:contact'),
|
||||||
|
// Exit values
|
||||||
|
array('result'=>'tns:result','id'=>'xsd:string'),
|
||||||
|
$ns,
|
||||||
|
$ns.'#updateContact',
|
||||||
|
$styledoc,
|
||||||
|
$styleuse,
|
||||||
|
'WS to update a contact'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,12 +259,16 @@ function getContact($authentication,$id,$ref='',$ref_ext='')
|
|||||||
{
|
{
|
||||||
$fuser->getrights();
|
$fuser->getrights();
|
||||||
|
|
||||||
if ($fuser->rights->societe->contact->lire )
|
$contact=new Contact($db);
|
||||||
|
$result=$contact->fetch($id,$ref,$ref_ext);
|
||||||
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$contact=new Contact($db);
|
// Only internal user who have contact read permission
|
||||||
$result=$contact->fetch($id,$ref,$ref_ext);
|
// Or for external user who have contact read permission, with restrict on societe_id
|
||||||
if ($result > 0)
|
if (
|
||||||
{
|
$fuser->rights->societe->contact->lire && !$fuser->societe_id
|
||||||
|
|| ( $fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid))
|
||||||
|
){
|
||||||
$contact_result_fields =array(
|
$contact_result_fields =array(
|
||||||
'id' => $contact->id,
|
'id' => $contact->id,
|
||||||
'lastname' => $contact->lastname,
|
'lastname' => $contact->lastname,
|
||||||
@ -305,18 +321,18 @@ function getContact($authentication,$id,$ref='',$ref_ext='')
|
|||||||
'result'=>array('result_code'=>'OK', 'result_label'=>''),
|
'result'=>array('result_code'=>'OK', 'result_label'=>''),
|
||||||
'contact'=>$contact_result_fields
|
'contact'=>$contact_result_fields
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
|
$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
|
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
@ -581,6 +597,112 @@ function getContactsForThirdParty($authentication,$idthirdparty)
|
|||||||
return $objectresp;
|
return $objectresp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a contact
|
||||||
|
*
|
||||||
|
* @param array $authentication Array of authentication information
|
||||||
|
* @param Contact $contact Contact
|
||||||
|
* @return array Array result
|
||||||
|
*/
|
||||||
|
function updateContact($authentication,$contact)
|
||||||
|
{
|
||||||
|
global $db,$conf,$langs;
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
|
dol_syslog("Function: updateContact login=".$authentication['login']);
|
||||||
|
|
||||||
|
if ($authentication['entity']) $conf->entity=$authentication['entity'];
|
||||||
|
|
||||||
|
// Init and check authentication
|
||||||
|
$objectresp=array();
|
||||||
|
$errorcode='';$errorlabel='';
|
||||||
|
$error=0;
|
||||||
|
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
|
||||||
|
// Check parameters
|
||||||
|
if (empty($contact['id'])) {
|
||||||
|
$error++; $errorcode='KO'; $errorlabel="Contact id is mandatory.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$objectfound=false;
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
|
|
||||||
|
$object=new Contact($db);
|
||||||
|
$result=$object->fetch($contact['id']);
|
||||||
|
|
||||||
|
if (!empty($object->id)) {
|
||||||
|
|
||||||
|
$objectfound=true;
|
||||||
|
|
||||||
|
|
||||||
|
$object->firstname=$contact['firstname'];
|
||||||
|
$object->lastname=$contact['lastname'];
|
||||||
|
|
||||||
|
$object->address=$contact['address'];
|
||||||
|
$object->zip=$contact['zip'];
|
||||||
|
$object->town=$contact['town'];
|
||||||
|
|
||||||
|
$object->country_id=$contact['country_id'];
|
||||||
|
if ($contact['country_code']) $object->country_id=getCountry($contact['country_code'],3);
|
||||||
|
$object->province_id=$contact['province_id'];
|
||||||
|
|
||||||
|
|
||||||
|
$object->phone_perso=$contact['phone_perso'];
|
||||||
|
$object->phone_mobile=$contact['phone_mobile'];
|
||||||
|
$object->fax=$contact['fax'];
|
||||||
|
$object->email=$contact['email'];
|
||||||
|
|
||||||
|
|
||||||
|
//Retreive all extrafield for contact
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$extrafields=new ExtraFields($db);
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label('contact',true);
|
||||||
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
|
{
|
||||||
|
$key='options_'.$key;
|
||||||
|
$object->array_options[$key]=$contact[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$result=$object->update($contact['id'],$fuser);
|
||||||
|
if ($result <= 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((! $error) && ($objectfound))
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
$objectresp=array(
|
||||||
|
'result'=>array('result_code'=>'OK', 'result_label'=>''),
|
||||||
|
'id'=>$object->id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif ($objectfound)
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
$error++;
|
||||||
|
$errorcode='KO';
|
||||||
|
$errorlabel=$object->error;
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
$errorcode='NOT_FOUND';
|
||||||
|
$errorlabel='Contact id='.$contact['id'].' cannot be found';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error)
|
||||||
|
{
|
||||||
|
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $objectresp;
|
||||||
|
}
|
||||||
// Return the results.
|
// Return the results.
|
||||||
$server->service($HTTP_RAW_POST_DATA);
|
$server->service($HTTP_RAW_POST_DATA);
|
||||||
|
|
||||||
|
|||||||
@ -151,6 +151,7 @@ $server->wsdl->addComplexType(
|
|||||||
),
|
),
|
||||||
'tns:group'
|
'tns:group'
|
||||||
);
|
);
|
||||||
|
|
||||||
$thirdpartywithuser_fields = array(
|
$thirdpartywithuser_fields = array(
|
||||||
// For thirdparty and contact
|
// For thirdparty and contact
|
||||||
'name' => array('name'=>'name','type'=>'xsd:string'),
|
'name' => array('name'=>'name','type'=>'xsd:string'),
|
||||||
@ -211,6 +212,20 @@ $server->wsdl->addComplexType(
|
|||||||
$thirdpartywithuser_fields
|
$thirdpartywithuser_fields
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Define WSDL user short object
|
||||||
|
$server->wsdl->addComplexType(
|
||||||
|
'shortuser',
|
||||||
|
'complexType',
|
||||||
|
'struct',
|
||||||
|
'all',
|
||||||
|
'',
|
||||||
|
array(
|
||||||
|
'login' => array('name'=>'login','type'=>'xsd:string'),
|
||||||
|
'password' => array('name'=>'password','type'=>'xsd:string'),
|
||||||
|
'entity' => array('name'=>'entity','type'=>'xsd:string'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
|
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
|
||||||
@ -261,6 +276,19 @@ $server->register(
|
|||||||
'WS to create an external user with thirdparty and contact'
|
'WS to create an external user with thirdparty and contact'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$server->register(
|
||||||
|
'SetUserPassword',
|
||||||
|
// Entry values
|
||||||
|
array('authentication'=>'tns:authentication','shortuser'=>'tns:shortuser'),
|
||||||
|
// Exit values
|
||||||
|
array('result'=>'tns:result','id'=>'xsd:string'),
|
||||||
|
$ns,
|
||||||
|
$ns.'#SetUserPassword',
|
||||||
|
$styledoc,
|
||||||
|
$styleuse,
|
||||||
|
'WS to change password of an user'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -554,10 +582,9 @@ function CreateUserFromThirdparty($authentication,$thirdpartywithuser)
|
|||||||
foreach($extrafields->attribute_label as $key=>$label)
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
{
|
{
|
||||||
$key='contact_options_'.$key;
|
$key='contact_options_'.$key;
|
||||||
|
$key=substr($key,8); // Remove 'contact_' prefix
|
||||||
$contact->array_options[$key]=$thirdpartywithuser[$key];
|
$contact->array_options[$key]=$thirdpartywithuser[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$contact_id = $contact->create($fuser);
|
$contact_id = $contact->create($fuser);
|
||||||
|
|
||||||
@ -630,6 +657,86 @@ function CreateUserFromThirdparty($authentication,$thirdpartywithuser)
|
|||||||
return $objectresp;
|
return $objectresp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set password of an user
|
||||||
|
*
|
||||||
|
* @param array $authentication Array of authentication information
|
||||||
|
* @param array $shortuser Array of login/password info
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function SetUserPassword($authentication,$shortuser) {
|
||||||
|
|
||||||
|
global $db,$conf,$langs;
|
||||||
|
|
||||||
|
dol_syslog("Function: SetUserPassword login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
|
||||||
|
|
||||||
|
if ($authentication['entity']) $conf->entity=$authentication['entity'];
|
||||||
|
|
||||||
|
$objectresp=array();
|
||||||
|
$errorcode='';$errorlabel='';
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
|
||||||
|
|
||||||
|
if ($fuser->societe_id) $socid=$fuser->societe_id;
|
||||||
|
|
||||||
|
if (! $error && ! $shortuser)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter shortuser must be provided.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$fuser->getrights();
|
||||||
|
|
||||||
|
if ($fuser->rights->user->user->password || $fuser->rights->user->self->password)
|
||||||
|
{
|
||||||
|
$userstat=new User($db);
|
||||||
|
$res = $userstat->fetch('',$shortuser['login']);
|
||||||
|
if($res)
|
||||||
|
{
|
||||||
|
$res = $userstat->setPassword($userstat,$shortuser['password']);
|
||||||
|
if($res)
|
||||||
|
{
|
||||||
|
$objectresp = array(
|
||||||
|
'result'=>array('result_code' => 'OK', 'result_label' => ''),
|
||||||
|
'groups'=>$arraygroups
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$errorcode='NOT_MODIFIED'; $errorlabel='Error when changing password';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$errorcode='NOT_FOUND'; $errorlabel='User not found';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($error)
|
||||||
|
{
|
||||||
|
$objectresp = array(
|
||||||
|
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $objectresp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return the results.
|
// Return the results.
|
||||||
$server->service($HTTP_RAW_POST_DATA);
|
$server->service($HTTP_RAW_POST_DATA);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user