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");
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();
226 if (!$error && !$id) {
228 $errorcode =
'BAD_PARAMETERS';
229 $errorlabel =
"Parameter id must be provided.";
236 if ($fuser->hasRight(
'categorie',
'lire')) {
238 $result = $categorie->fetch($id);
240 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
241 $pdir =
get_exdir($categorie->id, 2, 0, 0, $categorie,
'category').$categorie->id.
"/photos/";
242 $dir = $dir.
'/'.$pdir;
245 'id' => $categorie->id,
246 'id_mere' => $categorie->id_mere,
247 'label' => $categorie->label,
248 'description' => $categorie->description,
249 'socid' => $categorie->socid,
251 'type' => $categorie->type,
253 'photos' => $categorie->liste_photos($dir, $nbmax)
256 $cats = $categorie->get_filles();
257 if (count($cats) > 0) {
258 foreach ($cats as $fille) {
259 $dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
260 $pdir =
get_exdir($fille->id, 2, 0, 0, $categorie,
'category').$fille->id.
"/photos/";
261 $dir = $dir.
'/'.$pdir;
262 $cat[
'filles'][] = array(
264 'id_mere' => $categorie->id_mere,
265 'label'=>$fille->label,
266 'description'=>$fille->description,
267 'socid'=>$fille->socid,
269 'type'=>$fille->type,
271 'photos' => $fille->liste_photos($dir, $nbmax)
278 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
283 $errorcode =
'NOT_FOUND';
284 $errorlabel =
'Object not found for id='.$id;
288 $errorcode =
'PERMISSION_DENIED';
289 $errorlabel =
'User does not have permission for this request';
294 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
301$server->service(file_get_contents(
"php://input"));
Class to manage categories.
getDolGlobalString($key, $default='')
Return 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.