24if (!defined(
'NOCSRFCHECK')) {
25 define(
'NOCSRFCHECK',
'1');
27if (!defined(
'NOTOKENRENEWAL')) {
28 define(
'NOTOKENRENEWAL',
'1');
30if (!defined(
'NOREQUIREMENU')) {
31 define(
'NOREQUIREMENU',
'1');
33if (!defined(
'NOREQUIREHTML')) {
34 define(
'NOREQUIREHTML',
'1');
36if (!defined(
'NOREQUIREAJAX')) {
37 define(
'NOREQUIREAJAX',
'1');
39if (!defined(
"NOLOGIN")) {
40 define(
"NOLOGIN",
'1');
42if (!defined(
"NOSESSION")) {
43 define(
"NOSESSION",
'1');
46require
'../main.inc.php';
47require_once NUSOAP_PATH.
'/nusoap.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
49require_once DOL_DOCUMENT_ROOT.
"/categories/class/categorie.class.php";
52dol_syslog(
"Call Dolibarr webservices interfaces");
55if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
56 $langs->load(
"admin");
57 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
58 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
59 print $langs->trans(
"ToActivateModule");
64$server =
new nusoap_server();
65$server->soap_defencoding =
'UTF-8';
66$server->decode_utf8 =
false;
67$ns =
'http://www.dolibarr.org/ns/';
68$server->configureWSDL(
'WebServicesDolibarrCategorie', $ns);
69$server->wsdl->schemaTargetNamespace = $ns;
73$server->wsdl->addComplexType(
80 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
81 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
82 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
83 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
84 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
91$server->wsdl->addComplexType(
98 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
99 'id_mere' => array(
'name'=>
'id_mere',
'type'=>
'xsd:string'),
100 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
101 'description' => array(
'name'=>
'description',
'type'=>
'xsd:string'),
102 'socid' => array(
'name'=>
'socid',
'type'=>
'xsd:string'),
103 'type' => array(
'name'=>
'type',
'type'=>
'xsd:string'),
104 'visible' => array(
'name'=>
'visible',
'type'=>
'xsd:string'),
105 'dir'=> array(
'name'=>
'dir',
'type'=>
'xsd:string'),
106 'photos' => array(
'name'=>
'photos',
'type'=>
'tns:PhotosArray'),
107 'filles' => array(
'name'=>
'filles',
'type'=>
'tns:FillesArray')
114$server->wsdl->addComplexType(
122 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:categorie[]')
130$server->wsdl->addComplexType(
139 'type' =>
'tns:image',
141 'maxOccurs' =>
'unbounded'
149$server->wsdl->addComplexType(
156 'photo' => array(
'name'=>
'photo',
'type'=>
'xsd:string'),
157 'photo_vignette' => array(
'name'=>
'photo_vignette',
'type'=>
'xsd:string'),
158 'imgWidth' => array(
'name'=>
'imgWidth',
'type'=>
'xsd:string'),
159 'imgHeight' => array(
'name'=>
'imgHeight',
'type'=>
'xsd:string')
166$server->wsdl->addComplexType(
173 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
174 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
182$styleuse =
'encoded';
190 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string'),
192 array(
'result'=>
'tns:result',
'categorie'=>
'tns:categorie'),
210 global $db, $conf, $langs;
214 dol_syslog(
"Function: getCategory login=".$authentication[
'login'].
" id=".$id);
216 if ($authentication[
'entity']) {
217 $conf->entity = $authentication[
'entity'];
220 $objectresp = array();
221 $errorcode =
''; $errorlabel =
'';
225 if (!$error && !$id) {
227 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id must be provided.";
234 if ($fuser->rights->categorie->lire) {
236 $result = $categorie->fetch($id);
238 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
239 $pdir =
get_exdir($categorie->id, 2, 0, 0, $categorie,
'category').$categorie->id.
"/photos/";
240 $dir = $dir.
'/'.$pdir;
243 'id' => $categorie->id,
244 'id_mere' => $categorie->id_mere,
245 'label' => $categorie->label,
246 'description' => $categorie->description,
247 'socid' => $categorie->socid,
249 'type' => $categorie->type,
251 'photos' => $categorie->liste_photos($dir, $nbmax)
254 $cats = $categorie->get_filles();
255 if (count($cats) > 0) {
256 foreach ($cats as $fille) {
257 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
258 $pdir =
get_exdir($fille->id, 2, 0, 0, $categorie,
'category').$fille->id.
"/photos/";
259 $dir = $dir.
'/'.$pdir;
260 $cat[
'filles'][] = array(
262 'id_mere' => $categorie->id_mere,
263 'label'=>$fille->label,
264 'description'=>$fille->description,
265 'socid'=>$fille->socid,
267 'type'=>$fille->type,
269 'photos' => $fille->liste_photos($dir, $nbmax)
276 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
281 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id;
285 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
290 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
297$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.