25if (!defined(
'NOCSRFCHECK')) {
26 define(
'NOCSRFCHECK',
'1');
28if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL',
'1');
31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
40if (!defined(
"NOLOGIN")) {
41 define(
"NOLOGIN",
'1');
43if (!defined(
"NOSESSION")) {
44 define(
"NOSESSION",
'1');
47require
'../main.inc.php';
48require_once NUSOAP_PATH.
'/nusoap.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
50require_once DOL_DOCUMENT_ROOT.
"/categories/class/categorie.class.php";
53dol_syslog(
"Call Dolibarr webservices interfaces");
57 $langs->load(
"admin");
58 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
59 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
60 print $langs->trans(
"ToActivateModule");
65$server =
new nusoap_server();
66$server->soap_defencoding =
'UTF-8';
67$server->decode_utf8 =
false;
68$ns =
'http://www.dolibarr.org/ns/';
69$server->configureWSDL(
'WebServicesDolibarrCategorie', $ns);
70$server->wsdl->schemaTargetNamespace = $ns;
74$server->wsdl->addComplexType(
81 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
82 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
83 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
84 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
85 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
92$server->wsdl->addComplexType(
99 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
100 'id_mere' => array(
'name' =>
'id_mere',
'type' =>
'xsd:string'),
101 'label' => array(
'name' =>
'label',
'type' =>
'xsd:string'),
102 'description' => array(
'name' =>
'description',
'type' =>
'xsd:string'),
103 'socid' => array(
'name' =>
'socid',
'type' =>
'xsd:string'),
104 'type' => array(
'name' =>
'type',
'type' =>
'xsd:string'),
105 'visible' => array(
'name' =>
'visible',
'type' =>
'xsd:string'),
106 'dir' => array(
'name' =>
'dir',
'type' =>
'xsd:string'),
107 'photos' => array(
'name' =>
'photos',
'type' =>
'tns:PhotosArray'),
108 'filles' => array(
'name' =>
'filles',
'type' =>
'tns:FillesArray')
115$server->wsdl->addComplexType(
123 array(
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'tns:categorie[]')
131$server->wsdl->addComplexType(
140 'type' =>
'tns:image',
142 'maxOccurs' =>
'unbounded'
150$server->wsdl->addComplexType(
157 'photo' => array(
'name' =>
'photo',
'type' =>
'xsd:string'),
158 'photo_vignette' => array(
'name' =>
'photo_vignette',
'type' =>
'xsd:string'),
159 'imgWidth' => array(
'name' =>
'imgWidth',
'type' =>
'xsd:string'),
160 'imgHeight' => array(
'name' =>
'imgHeight',
'type' =>
'xsd:string')
167$server->wsdl->addComplexType(
174 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
175 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
183$styleuse =
'encoded';
191 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string'),
193 array(
'result' =>
'tns:result',
'categorie' =>
'tns:categorie'),
211 global $db, $conf, $langs;
215 dol_syslog(
"Function: getCategory login=".$authentication[
'login'].
" id=".
$id);
217 if ($authentication[
'entity']) {
218 $conf->entity = $authentication[
'entity'];
221 $objectresp = array();
227 if (!$error && !
$id) {
229 $errorcode =
'BAD_PARAMETERS';
230 $errorlabel =
"Parameter id must be provided.";
234 $fuser->loadRights();
237 if ($fuser->hasRight(
'categorie',
'lire')) {
239 $result = $categorie->fetch(
$id);
241 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
242 $pdir =
get_exdir($categorie->id, 2, 0, 0, $categorie,
'category').$categorie->id.
"/photos/";
243 $dir = $dir.
'/'.$pdir;
246 'id' => $categorie->id,
247 'id_mere' => $categorie->id_mere,
248 'label' => $categorie->label,
249 'description' => $categorie->description,
250 'socid' => $categorie->socid,
252 'type' => $categorie->type,
254 'photos' => $categorie->liste_photos($dir, $nbmax)
257 $cats = $categorie->get_filles();
258 if (count($cats) > 0) {
259 foreach ($cats as $child_cat) {
260 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
261 $pdir =
get_exdir($child_cat->id, 2, 0, 0, $categorie,
'category').$child_cat->id.
"/photos/";
262 $dir = $dir.
'/'.$pdir;
263 $cat[
'filles'][] = array(
264 'id' => $child_cat->id,
265 'id_mere' => $categorie->id_mere,
266 'label' => $child_cat->label,
267 'description' => $child_cat->description,
268 'socid' => $child_cat->socid,
270 'type' => $child_cat->type,
272 'photos' => $child_cat->liste_photos($dir, $nbmax)
279 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
284 $errorcode =
'NOT_FOUND';
285 $errorlabel =
'Object not found for id='.$id;
289 $errorcode =
'PERMISSION_DENIED';
290 $errorlabel =
'User does not have permission for this request';
295 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
302$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.
getCategory($authentication, $id)
Get category infos and children.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.