26if (!defined(
'NOCSRFCHECK')) {
27 define(
'NOCSRFCHECK',
'1');
29if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL',
'1');
32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
41if (!defined(
"NOLOGIN")) {
42 define(
"NOLOGIN",
'1');
44if (!defined(
"NOSESSION")) {
45 define(
"NOSESSION",
'1');
48require
'../main.inc.php';
49require_once NUSOAP_PATH.
'/nusoap.php';
50require_once DOL_DOCUMENT_ROOT.
"/core/lib/ws.lib.php";
52require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/actioncomm.class.php";
53require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/cactioncomm.class.php";
54require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
57dol_syslog(
"Call ActionComm webservices interfaces");
61 $langs->load(
"admin");
62 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
63 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
64 print $langs->trans(
"ToActivateModule");
69$server =
new nusoap_server();
70$server->soap_defencoding =
'UTF-8';
71$server->decode_utf8 =
false;
72$ns =
'http://www.dolibarr.org/ns/';
73$server->configureWSDL(
'WebServicesDolibarrActionComm', $ns);
74$server->wsdl->schemaTargetNamespace = $ns;
78$server->wsdl->addComplexType(
85 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
86 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
87 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
88 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
89 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
94$server->wsdl->addComplexType(
101 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
102 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
107$actioncomm_fields = array(
108 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
109 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
110 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
111 'type_id' => array(
'name'=>
'type_id',
'type'=>
'xsd:string'),
112 'type_code' => array(
'name'=>
'type_code',
'type'=>
'xsd:string'),
113 'type' => array(
'name'=>
'type',
'type'=>
'xsd:string'),
114 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
115 'datep' => array(
'name'=>
'datep',
'type'=>
'xsd:dateTime'),
116 'datef' => array(
'name'=>
'datef',
'type'=>
'xsd:dateTime'),
117 'datec' => array(
'name'=>
'datec',
'type'=>
'xsd:dateTime'),
118 'datem' => array(
'name'=>
'datem',
'type'=>
'xsd:dateTime'),
119 'note' => array(
'name'=>
'note',
'type'=>
'xsd:string'),
120 'percentage' => array(
'name'=>
'percentage',
'type'=>
'xsd:string'),
121 'author' => array(
'name'=>
'author',
'type'=>
'xsd:string'),
122 'usermod' => array(
'name'=>
'usermod',
'type'=>
'xsd:string'),
123 'userownerid' => array(
'name'=>
'userownerid',
'type'=>
'xsd:string'),
124 'priority' => array(
'name'=>
'priority',
'type'=>
'xsd:string'),
125 'fulldayevent' => array(
'name'=>
'fulldayevent',
'type'=>
'xsd:string'),
126 'location' => array(
'name'=>
'location',
'type'=>
'xsd:string'),
127 'socid' => array(
'name'=>
'socid',
'type'=>
'xsd:string'),
128 'contactid' => array(
'name'=>
'contactid',
'type'=>
'xsd:string'),
129 'projectid' => array(
'name'=>
'projectid',
'type'=>
'xsd:string'),
130 'fk_element' => array(
'name'=>
'fk_element',
'type'=>
'xsd:string'),
131 'elementtype' => array(
'name'=>
'elementtype',
'type'=>
'xsd:string'));
134$elementtype =
'actioncomm';
139$extrafields->fetch_name_optionals_label($elementtype,
true);
140$extrafield_array =
null;
141if (is_array($extrafields) && count($extrafields) > 0) {
142 $extrafield_array = array();
144if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
145 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
146 $type = $extrafields->attributes[$elementtype][
'type'][$key];
147 if ($type ==
'date' || $type ==
'datetime') {
148 $type =
'xsd:dateTime';
150 $type =
'xsd:string';
153 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
156if (is_array($extrafield_array)) {
157 $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
161$server->wsdl->addComplexType(
171$server->wsdl->addComplexType(
178 'code' => array(
'name'=>
'code',
'type'=>
'xsd:string'),
179 'libelle' => array(
'name'=>
'libelle',
'type'=>
'xsd:string')
183$server->wsdl->addComplexType(
190 'actioncommtype' => array(
191 'name' =>
'actioncommtype',
192 'type' =>
'tns:actioncommtype',
194 'maxOccurs' =>
'unbounded'
204$styleuse =
'encoded';
210 'getListActionCommType',
212 array(
'authentication'=>
'tns:authentication'),
214 array(
'result'=>
'tns:result',
'actioncommtypes'=>
'tns:actioncommtypes'),
216 $ns.
'#getListActionCommType',
219 'WS to get actioncommType'
226 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string'),
228 array(
'result'=>
'tns:result',
'actioncomm'=>
'tns:actioncomm'),
230 $ns.
'#getActionComm',
233 'WS to get actioncomm'
240 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
242 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
244 $ns.
'#createActionComm',
247 'WS to create a actioncomm'
254 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
256 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
258 $ns.
'#updateActionComm',
261 'WS to update a actioncomm'
276 global $db, $conf, $langs;
278 dol_syslog(
"Function: getActionComm login=".$authentication[
'login'].
" id=".$id);
280 if ($authentication[
'entity']) {
281 $conf->entity = $authentication[
'entity'];
285 $objectresp = array();
291 if ($error || (!$id)) {
293 $errorcode =
'BAD_PARAMETERS';
294 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
300 if ($fuser->hasRight(
'agenda',
'allactions',
'read')) {
302 $result = $actioncomm->fetch($id);
304 $actioncomm_result_fields = array(
305 'id' => $actioncomm->id,
306 'ref'=> $actioncomm->ref,
307 'ref_ext'=> $actioncomm->ref_ext,
308 'type_id'=> $actioncomm->type_id,
309 'type_code'=> $actioncomm->type_code,
310 'type'=> $actioncomm->type,
311 'label'=> $actioncomm->label,
316 'note'=> $actioncomm->note_private,
317 'percentage'=> $actioncomm->percentage,
318 'author'=> $actioncomm->authorid,
319 'usermod'=> $actioncomm->usermodid,
320 'userownerid'=> $actioncomm->userownerid,
321 'priority'=> $actioncomm->priority,
322 'fulldayevent'=> $actioncomm->fulldayevent,
323 'location'=> $actioncomm->location,
324 'socid'=> $actioncomm->socid,
325 'contactid'=> $actioncomm->contact_id,
326 'projectid'=> $actioncomm->fk_project,
327 'fk_element'=> $actioncomm->fk_element,
328 'elementtype'=> $actioncomm->elementtype
331 $elementtype =
'actioncomm';
336 $extrafields->fetch_name_optionals_label($elementtype,
true);
338 $actioncomm->fetch_optionals();
340 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
341 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
342 $actioncomm_result_fields = array_merge($actioncomm_result_fields, array(
'options_'.$key => $actioncomm->array_options[
'options_'.$key]));
348 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
349 'actioncomm'=>$actioncomm_result_fields);
352 $errorcode =
'NOT_FOUND';
353 $errorlabel =
'Object not found for id='.$id;
357 $errorcode =
'PERMISSION_DENIED';
358 $errorlabel =
'User does not have permission for this request';
363 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
378 global $db, $conf, $langs;
380 dol_syslog(
"Function: getListActionCommType login=".$authentication[
'login']);
382 if ($authentication[
'entity']) {
383 $conf->entity = $authentication[
'entity'];
387 $objectresp = array();
396 if ($fuser->hasRight(
'agenda',
'myactions',
'read')) {
398 $result = $cactioncomm->liste_array(
'',
'code');
400 $resultarray = array();
401 foreach ($cactioncomm->liste_array as $code => $libeller) {
402 $resultarray[] = array(
'code'=>$code,
'libelle'=>$libeller);
406 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
407 'actioncommtypes'=>$resultarray);
410 $errorcode =
'NOT_FOUND';
411 $errorlabel =
'Failed to execute liste_array';
415 $errorcode =
'PERMISSION_DENIED';
416 $errorlabel =
'User does not have permission for this request';
421 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
437 global $db, $conf, $langs;
441 dol_syslog(
"Function: createActionComm login=".$authentication[
'login']);
443 if ($authentication[
'entity']) {
444 $conf->entity = $authentication[
'entity'];
448 $objectresp = array();
457 $newobject->datep = $actioncomm[
'datep'];
458 $newobject->datef = $actioncomm[
'datef'];
459 $newobject->type_code = $actioncomm[
'type_code'];
460 $newobject->socid = $actioncomm[
'socid'];
461 $newobject->fk_project = $actioncomm[
'projectid'];
462 $newobject->note = $actioncomm[
'note'];
463 $newobject->contact_id = $actioncomm[
'contactid'];
464 $newobject->userownerid = $actioncomm[
'userownerid'];
465 $newobject->label = $actioncomm[
'label'];
466 $newobject->percentage = $actioncomm[
'percentage'];
467 $newobject->priority = $actioncomm[
'priority'];
468 $newobject->fulldayevent = $actioncomm[
'fulldayevent'];
469 $newobject->location = $actioncomm[
'location'];
470 $newobject->fk_element = $actioncomm[
'fk_element'];
471 $newobject->elementtype = $actioncomm[
'elementtype'];
473 $elementtype =
'actioncomm';
478 $extrafields->fetch_name_optionals_label($elementtype,
true);
479 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
480 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
481 $key =
'options_'.$key;
482 $newobject->array_options[$key] = $actioncomm[$key];
488 $result = $newobject->create($fuser);
495 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id);
500 $errorlabel = $newobject->error;
505 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
520 global $db, $conf, $langs;
524 dol_syslog(
"Function: updateActionComm login=".$authentication[
'login']);
526 if ($authentication[
'entity']) {
527 $conf->entity = $authentication[
'entity'];
531 $objectresp = array();
537 if (empty($actioncomm[
'id'])) {
540 $errorlabel =
"Actioncomm id is mandatory.";
544 $objectfound =
false;
547 $result = $object->fetch($actioncomm[
'id']);
549 if (!empty($object->id)) {
552 $object->datep = $actioncomm[
'datep'];
553 $object->datef = $actioncomm[
'datef'];
554 $object->type_code = $actioncomm[
'type_code'];
555 $object->socid = $actioncomm[
'socid'];
556 $object->contact_id = $actioncomm[
'contactid'];
557 $object->fk_project = $actioncomm[
'projectid'];
558 $object->note = $actioncomm[
'note'];
559 $object->userownerid = $actioncomm[
'userownerid'];
560 $object->label = $actioncomm[
'label'];
561 $object->percentage = $actioncomm[
'percentage'];
562 $object->priority = $actioncomm[
'priority'];
563 $object->fulldayevent = $actioncomm[
'fulldayevent'];
564 $object->location = $actioncomm[
'location'];
565 $object->fk_element = $actioncomm[
'fk_element'];
566 $object->elementtype = $actioncomm[
'elementtype'];
568 $elementtype =
'actioncomm';
573 $extrafields->fetch_name_optionals_label($elementtype,
true);
574 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
575 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
576 $key =
'options_'.$key;
577 $object->array_options[$key] = $actioncomm[$key];
583 $result = $object->update($fuser);
589 if ((!$error) && ($objectfound)) {
592 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
595 } elseif ($objectfound) {
599 $errorlabel = $object->error;
602 $errorcode =
'NOT_FOUND';
603 $errorlabel =
'Actioncomm id='.$actioncomm[
'id'].
' cannot be found';
608 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
615$server->service(file_get_contents(
"php://input"));
Class to manage agenda events (actions)
Class to manage different types of events.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
createActionComm($authentication, $actioncomm)
Create ActionComm.
getListActionCommType($authentication)
Get getListActionCommType.
getActionComm($authentication, $id)
Get ActionComm.
updateActionComm($authentication, $actioncomm)
Create ActionComm.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.