24 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK",
'1');
26 require
"../master.inc.php";
27 require_once NUSOAP_PATH.
'/nusoap.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
"/categories/class/categorie.class.php";
32 dol_syslog(
"Call Dolibarr webservices interfaces");
35 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
37 $langs->load(
"admin");
38 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
39 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
40 print $langs->trans(
"ToActivateModule");
45 $server =
new nusoap_server();
46 $server->soap_defencoding =
'UTF-8';
47 $server->decode_utf8 =
false;
48 $ns =
'http://www.dolibarr.org/ns/';
49 $server->configureWSDL(
'WebServicesDolibarrCategorie', $ns);
50 $server->wsdl->schemaTargetNamespace = $ns;
54 $server->wsdl->addComplexType(
61 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
62 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
63 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
64 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
65 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
72 $server->wsdl->addComplexType(
79 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
80 'id_mere' => array(
'name'=>
'id_mere',
'type'=>
'xsd:string'),
81 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
82 'description' => array(
'name'=>
'description',
'type'=>
'xsd:string'),
83 'socid' => array(
'name'=>
'socid',
'type'=>
'xsd:string'),
84 'type' => array(
'name'=>
'type',
'type'=>
'xsd:string'),
85 'visible' => array(
'name'=>
'visible',
'type'=>
'xsd:string'),
86 'dir'=> array(
'name'=>
'dir',
'type'=>
'xsd:string'),
87 'photos' => array(
'name'=>
'photos',
'type'=>
'tns:PhotosArray'),
88 'filles' => array(
'name'=>
'filles',
'type'=>
'tns:FillesArray')
95 $server->wsdl->addComplexType(
103 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:categorie[]')
111 $server->wsdl->addComplexType(
120 'type' =>
'tns:image',
122 'maxOccurs' =>
'unbounded'
130 $server->wsdl->addComplexType(
137 'photo' => array(
'name'=>
'photo',
'type'=>
'xsd:string'),
138 'photo_vignette' => array(
'name'=>
'photo_vignette',
'type'=>
'xsd:string'),
139 'imgWidth' => array(
'name'=>
'imgWidth',
'type'=>
'xsd:string'),
140 'imgHeight' => array(
'name'=>
'imgHeight',
'type'=>
'xsd:string')
147 $server->wsdl->addComplexType(
154 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
155 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
163 $styleuse =
'encoded';
171 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string'),
173 array(
'result'=>
'tns:result',
'categorie'=>
'tns:categorie'),
191 global $db, $conf, $langs;
195 dol_syslog(
"Function: getCategory login=".$authentication[
'login'].
" id=".$id);
197 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
199 $objectresp = array();
200 $errorcode =
''; $errorlabel =
'';
207 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id must be provided.";
215 if ($fuser->rights->categorie->lire)
218 $result = $categorie->fetch($id);
221 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
222 $pdir =
get_exdir($categorie->id, 2, 0, 0, $categorie,
'category').$categorie->id.
"/photos/";
223 $dir = $dir.
'/'.$pdir;
226 'id' => $categorie->id,
227 'id_mere' => $categorie->id_mere,
228 'label' => $categorie->label,
229 'description' => $categorie->description,
230 'socid' => $categorie->socid,
232 'type' => $categorie->type,
234 'photos' => $categorie->liste_photos($dir, $nbmax)
237 $cats = $categorie->get_filles();
238 if (count($cats) > 0)
240 foreach ($cats as $fille)
242 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
243 $pdir =
get_exdir($fille->id, 2, 0, 0, $categorie,
'category').$fille->id.
"/photos/";
244 $dir = $dir.
'/'.$pdir;
245 $cat[
'filles'][] = array(
247 'id_mere' => $categorie->id_mere,
248 'label'=>$fille->label,
249 'description'=>$fille->description,
250 'socid'=>$fille->socid,
252 'type'=>$fille->type,
254 'photos' => $fille->liste_photos($dir, $nbmax)
261 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
267 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id;
272 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
278 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
285 $server->service(file_get_contents(
"php://input"));
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.
getCategory($authentication, $id)
Get category infos and children.
Class to manage categories.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
print
Draft customers invoices.