24 if (!defined(
"NOCSRFCHECK")) {
25 define(
"NOCSRFCHECK",
'1');
28 require
"../master.inc.php";
29 require_once NUSOAP_PATH.
'/nusoap.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
"/categories/class/categorie.class.php";
34 dol_syslog(
"Call Dolibarr webservices interfaces");
37 if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
38 $langs->load(
"admin");
39 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
40 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
41 print $langs->trans(
"ToActivateModule");
46 $server =
new nusoap_server();
47 $server->soap_defencoding =
'UTF-8';
48 $server->decode_utf8 =
false;
49 $ns =
'http://www.dolibarr.org/ns/';
50 $server->configureWSDL(
'WebServicesDolibarrCategorie', $ns);
51 $server->wsdl->schemaTargetNamespace = $ns;
55 $server->wsdl->addComplexType(
62 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
63 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
64 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
65 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
66 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
73 $server->wsdl->addComplexType(
80 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
81 'id_mere' => array(
'name'=>
'id_mere',
'type'=>
'xsd:string'),
82 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
83 'description' => array(
'name'=>
'description',
'type'=>
'xsd:string'),
84 'socid' => array(
'name'=>
'socid',
'type'=>
'xsd:string'),
85 'type' => array(
'name'=>
'type',
'type'=>
'xsd:string'),
86 'visible' => array(
'name'=>
'visible',
'type'=>
'xsd:string'),
87 'dir'=> array(
'name'=>
'dir',
'type'=>
'xsd:string'),
88 'photos' => array(
'name'=>
'photos',
'type'=>
'tns:PhotosArray'),
89 'filles' => array(
'name'=>
'filles',
'type'=>
'tns:FillesArray')
96 $server->wsdl->addComplexType(
104 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:categorie[]')
112 $server->wsdl->addComplexType(
121 'type' =>
'tns:image',
123 'maxOccurs' =>
'unbounded'
131 $server->wsdl->addComplexType(
138 'photo' => array(
'name'=>
'photo',
'type'=>
'xsd:string'),
139 'photo_vignette' => array(
'name'=>
'photo_vignette',
'type'=>
'xsd:string'),
140 'imgWidth' => array(
'name'=>
'imgWidth',
'type'=>
'xsd:string'),
141 'imgHeight' => array(
'name'=>
'imgHeight',
'type'=>
'xsd:string')
148 $server->wsdl->addComplexType(
155 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
156 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
164 $styleuse =
'encoded';
172 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string'),
174 array(
'result'=>
'tns:result',
'categorie'=>
'tns:categorie'),
192 global $db, $conf, $langs;
196 dol_syslog(
"Function: getCategory login=".$authentication[
'login'].
" id=".$id);
198 if ($authentication[
'entity']) {
199 $conf->entity = $authentication[
'entity'];
202 $objectresp = array();
203 $errorcode =
''; $errorlabel =
'';
207 if (!$error && !$id) {
209 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id must be provided.";
216 if ($fuser->rights->categorie->lire) {
218 $result = $categorie->fetch($id);
220 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
221 $pdir =
get_exdir($categorie->id, 2, 0, 0, $categorie,
'category').$categorie->id.
"/photos/";
222 $dir = $dir.
'/'.$pdir;
225 'id' => $categorie->id,
226 'id_mere' => $categorie->id_mere,
227 'label' => $categorie->label,
228 'description' => $categorie->description,
229 'socid' => $categorie->socid,
231 'type' => $categorie->type,
233 'photos' => $categorie->liste_photos($dir, $nbmax)
236 $cats = $categorie->get_filles();
237 if (count($cats) > 0) {
238 foreach ($cats as $fille) {
239 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
240 $pdir =
get_exdir($fille->id, 2, 0, 0, $categorie,
'category').$fille->id.
"/photos/";
241 $dir = $dir.
'/'.$pdir;
242 $cat[
'filles'][] = array(
244 'id_mere' => $categorie->id_mere,
245 'label'=>$fille->label,
246 'description'=>$fille->description,
247 'socid'=>$fille->socid,
249 'type'=>$fille->type,
251 'photos' => $fille->liste_photos($dir, $nbmax)
258 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
263 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id;
267 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
272 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
279 $server->service(file_get_contents(
"php://input"));
Class to manage categories.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getCategory($authentication, $id)
Get category infos and children.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.