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);
75$server->wsdl->schemaTargetNamespace = $ns;
79$server->wsdl->addComplexType(
86 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
87 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
88 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
89 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
90 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
97$server->wsdl->addComplexType(
104 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
105 'id_mere' => array(
'name' =>
'id_mere',
'type' =>
'xsd:string'),
106 'label' => array(
'name' =>
'label',
'type' =>
'xsd:string'),
107 'description' => array(
'name' =>
'description',
'type' =>
'xsd:string'),
108 'socid' => array(
'name' =>
'socid',
'type' =>
'xsd:string'),
109 'type' => array(
'name' =>
'type',
'type' =>
'xsd:string'),
110 'visible' => array(
'name' =>
'visible',
'type' =>
'xsd:string'),
111 'dir' => array(
'name' =>
'dir',
'type' =>
'xsd:string'),
112 'photos' => array(
'name' =>
'photos',
'type' =>
'tns:PhotosArray'),
113 'filles' => array(
'name' =>
'filles',
'type' =>
'tns:FillesArray')
120$server->wsdl->addComplexType(
128 array(
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'tns:categorie[]')
136$server->wsdl->addComplexType(
145 'type' =>
'tns:image',
147 'maxOccurs' =>
'unbounded'
155$server->wsdl->addComplexType(
162 'photo' => array(
'name' =>
'photo',
'type' =>
'xsd:string'),
163 'photo_vignette' => array(
'name' =>
'photo_vignette',
'type' =>
'xsd:string'),
164 'imgWidth' => array(
'name' =>
'imgWidth',
'type' =>
'xsd:string'),
165 'imgHeight' => array(
'name' =>
'imgHeight',
'type' =>
'xsd:string')
172$server->wsdl->addComplexType(
179 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
180 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
188$styleuse =
'encoded';
196 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string'),
198 array(
'result' =>
'tns:result',
'categorie' =>
'tns:categorie'),
220 dol_syslog(
"Function: getCategory login=".$authentication[
'login'].
" id=".
$id);
222 if ($authentication[
'entity']) {
223 $conf->entity = $authentication[
'entity'];
226 $objectresp = array();
232 if (!$error && !
$id) {
234 $errorcode =
'BAD_PARAMETERS';
235 $errorlabel =
"Parameter id must be provided.";
239 $fuser->loadRights();
242 if ($fuser->hasRight(
'categorie',
'lire')) {
244 $result = $categorie->fetch(
$id);
246 $dir = (!empty(
$conf->categorie->dir_output) ?
$conf->categorie->dir_output :
$conf->service->dir_output);
247 $pdir =
get_exdir($categorie->id, 2, 0, 0, $categorie,
'category').$categorie->id.
"/photos/";
248 $dir = $dir.
'/'.$pdir;
251 'id' => $categorie->id,
252 'id_mere' => $categorie->fk_parent,
253 'label' => $categorie->label,
254 'description' => $categorie->description,
255 'socid' => $categorie->socid,
257 'type' => $categorie->type,
259 'photos' => $categorie->liste_photos($dir, $nbmax)
262 $cats = $categorie->get_filles();
263 if (count($cats) > 0) {
264 foreach ($cats as $child_cat) {
265 $dir = (!empty(
$conf->categorie->dir_output) ?
$conf->categorie->dir_output :
$conf->service->dir_output);
266 $pdir =
get_exdir($child_cat->id, 2, 0, 0, $categorie,
'category').$child_cat->id.
"/photos/";
267 $dir = $dir.
'/'.$pdir;
268 $cat[
'filles'][] = array(
269 'id' => $child_cat->id,
270 'id_mere' => $categorie->fk_parent,
271 'label' => $child_cat->label,
272 'description' => $child_cat->description,
273 'socid' => $child_cat->socid,
275 'type' => $child_cat->type,
277 'photos' => $child_cat->liste_photos($dir, $nbmax)
284 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
289 $errorcode =
'NOT_FOUND';
290 $errorlabel =
'Object not found for id='.$id;
294 $errorcode =
'PERMISSION_DENIED';
295 $errorlabel =
'User does not have permission for this request';
300 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
307$server->service(file_get_contents(
"php://input"));
$id
Support class for third parties, contacts, members, users or resources.
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.
getCategory($authentication, $id)
Get category infos and children.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.