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';
51require_once DOL_DOCUMENT_ROOT.
"/categories/class/categorie.class.php";
57dol_syslog(
"Call Dolibarr 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(
'WebServicesDolibarrCategorie', $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'),
96$server->wsdl->addComplexType(
103 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
104 'id_mere' => array(
'name' =>
'id_mere',
'type' =>
'xsd:string'),
105 'label' => array(
'name' =>
'label',
'type' =>
'xsd:string'),
106 'description' => array(
'name' =>
'description',
'type' =>
'xsd:string'),
107 'socid' => array(
'name' =>
'socid',
'type' =>
'xsd:string'),
108 'type' => array(
'name' =>
'type',
'type' =>
'xsd:string'),
109 'visible' => array(
'name' =>
'visible',
'type' =>
'xsd:string'),
110 'dir' => array(
'name' =>
'dir',
'type' =>
'xsd:string'),
111 'photos' => array(
'name' =>
'photos',
'type' =>
'tns:PhotosArray'),
112 'filles' => array(
'name' =>
'filles',
'type' =>
'tns:FillesArray')
119$server->wsdl->addComplexType(
127 array(
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'tns:categorie[]')
135$server->wsdl->addComplexType(
144 'type' =>
'tns:image',
146 'maxOccurs' =>
'unbounded'
154$server->wsdl->addComplexType(
161 'photo' => array(
'name' =>
'photo',
'type' =>
'xsd:string'),
162 'photo_vignette' => array(
'name' =>
'photo_vignette',
'type' =>
'xsd:string'),
163 'imgWidth' => array(
'name' =>
'imgWidth',
'type' =>
'xsd:string'),
164 'imgHeight' => array(
'name' =>
'imgHeight',
'type' =>
'xsd:string')
171$server->wsdl->addComplexType(
178 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
179 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
187$styleuse =
'encoded';
195 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string'),
197 array(
'result' =>
'tns:result',
'categorie' =>
'tns:categorie'),
215 global $db,
$conf, $langs;
219 dol_syslog(
"Function: getCategory login=".$authentication[
'login'].
" id=".
$id);
221 if ($authentication[
'entity']) {
222 $conf->entity = $authentication[
'entity'];
225 $objectresp = array();
231 if (!$error && !
$id) {
233 $errorcode =
'BAD_PARAMETERS';
234 $errorlabel =
"Parameter id must be provided.";
238 $fuser->loadRights();
241 if ($fuser->hasRight(
'categorie',
'lire')) {
243 $result = $categorie->fetch(
$id);
245 $dir = (!empty(
$conf->categorie->dir_output) ?
$conf->categorie->dir_output :
$conf->service->dir_output);
246 $pdir =
get_exdir($categorie->id, 2, 0, 0, $categorie,
'category').$categorie->id.
"/photos/";
247 $dir = $dir.
'/'.$pdir;
250 'id' => $categorie->id,
251 'id_mere' => $categorie->id_mere,
252 'label' => $categorie->label,
253 'description' => $categorie->description,
254 'socid' => $categorie->socid,
256 'type' => $categorie->type,
258 'photos' => $categorie->liste_photos($dir, $nbmax)
261 $cats = $categorie->get_filles();
262 if (count($cats) > 0) {
263 foreach ($cats as $child_cat) {
264 $dir = (!empty(
$conf->categorie->dir_output) ?
$conf->categorie->dir_output :
$conf->service->dir_output);
265 $pdir =
get_exdir($child_cat->id, 2, 0, 0, $categorie,
'category').$child_cat->id.
"/photos/";
266 $dir = $dir.
'/'.$pdir;
267 $cat[
'filles'][] = array(
268 'id' => $child_cat->id,
269 'id_mere' => $categorie->id_mere,
270 'label' => $child_cat->label,
271 'description' => $child_cat->description,
272 'socid' => $child_cat->socid,
274 'type' => $child_cat->type,
276 'photos' => $child_cat->liste_photos($dir, $nbmax)
283 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
288 $errorcode =
'NOT_FOUND';
289 $errorlabel =
'Object not found for id='.$id;
293 $errorcode =
'PERMISSION_DENIED';
294 $errorlabel =
'User does not have permission for this request';
299 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
306$server->service(file_get_contents(
"php://input"));
Class to manage categories.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
getCategory($authentication, $id)
Get category infos and children.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.