source: trunk/ws.php @ 25196

Last change on this file since 25196 was 25196, checked in by mistic100, 10 years ago

feature 2976: add 'display' parameter for pwg.users.getList

  • Property svn:eol-style set to LF
File size: 32.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24define ('PHPWG_ROOT_PATH', './');
25
26include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
27check_status(ACCESS_FREE);
28include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php');
29
30if ( !$conf['allow_web_services'] )
31{
32  page_forbidden('Web services are disabled');
33}
34
35add_event_handler('ws_add_methods', 'ws_addDefaultMethods');
36
37add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
38
39$requestFormat = 'rest';
40$responseFormat = null;
41
42if ( isset($_GET['format']) )
43{
44  $responseFormat = $_GET['format'];
45}
46
47if ( !isset($responseFormat) and isset($requestFormat) )
48{
49  $responseFormat = $requestFormat;
50}
51
52$service = new PwgServer();
53
54if (!is_null($requestFormat))
55{
56  $handler = null;
57  switch ($requestFormat)
58  {
59    case 'rest':
60      include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_handler.php');
61      $handler = new PwgRestRequestHandler();
62      break;
63  }
64  $service->setHandler($requestFormat, $handler);
65}
66
67if (!is_null($responseFormat))
68{
69  $encoder = null;
70  switch ($responseFormat)
71  {
72    case 'rest':
73      include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_encoder.php');
74      $encoder = new PwgRestEncoder();
75      break;
76    case 'php':
77      include_once(PHPWG_ROOT_PATH.'include/ws_protocols/php_encoder.php');
78      $encoder = new PwgSerialPhpEncoder();
79      break;
80    case 'json':
81      include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php');
82      $encoder = new PwgJsonEncoder();
83      break;
84    case 'xmlrpc':
85      include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php');
86      $encoder = new PwgXmlRpcEncoder();
87      break;
88  }
89  $service->setEncoder($responseFormat, $encoder);
90}
91
92set_make_full_url();
93$service->run();
94
95
96/**
97 * event handler that registers standard methods with the web service
98 */
99function ws_addDefaultMethods( $arr )
100{
101  global $conf, $user;
102  $service = &$arr[0];
103 
104  include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php');
105 
106  $f_params = array(
107    'f_min_rate' => array('default'=>null,
108                          'type'=>WS_TYPE_FLOAT),
109    'f_max_rate' => array('default'=>null,
110                          'type'=>WS_TYPE_FLOAT),
111    'f_min_hit' =>  array('default'=>null,
112                          'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
113    'f_max_hit' =>  array('default'=>null,
114                          'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
115    'f_min_ratio' => array('default'=>null,
116                           'type'=>WS_TYPE_FLOAT|WS_TYPE_POSITIVE),
117    'f_max_ratio' => array('default'=>null,
118                           'type'=>WS_TYPE_FLOAT|WS_TYPE_POSITIVE),
119    'f_max_level' => array('default'=>null,
120                           'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
121    'f_min_date_available' => array('default'=>null),
122    'f_max_date_available' => array('default'=>null),
123    'f_min_date_created' =>   array('default'=>null),
124    'f_max_date_created' =>   array('default'=>null),
125    );
126 
127  $service->addMethod(
128      'pwg.getVersion',
129      'ws_getVersion',
130      null,
131      'Returns the Piwigo version.'
132    );
133         
134  $service->addMethod(
135      'pwg.getInfos',
136      'ws_getInfos',
137      null,
138      '<b>Admin only.</b> Returns general informations.',
139      null,
140      array('admin_only'=>true)
141    );
142
143  $service->addMethod(
144      'pwg.caddie.add',
145      'ws_caddie_add',
146      array(
147        'image_id'=> array('flags'=>WS_PARAM_FORCE_ARRAY,
148                           'type'=>WS_TYPE_ID),
149        ),
150      '<b>Admin only.</b> Adds elements to the caddie. Returns the number of elements added.',
151      null,
152      array('admin_only'=>true)
153    );
154
155  $service->addMethod(
156      'pwg.categories.getImages',
157      'ws_categories_getImages',
158      array_merge(array(
159        'cat_id' =>     array('default'=>null, 
160                              'flags'=>WS_PARAM_FORCE_ARRAY,
161                              'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
162        'recursive' =>  array('default'=>false,
163                              'type'=>WS_TYPE_BOOL),
164        'per_page' =>   array('default'=>100,
165                              'maxValue'=>$conf['ws_max_images_per_page'],
166                              'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
167        'page' =>       array('default'=>0,
168                              'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
169        'order' =>      array('default'=>null,
170                              'info'=>'id, file, name, hit, rating_score, date_creation, date_available, random'),
171        ), $f_params),
172      'Returns elements for the corresponding categories.
173<br><b>cat_id</b> can be empty if <b>recursive</b> is true.
174<br><b>order</b> comma separated fields for sorting'
175    );
176
177  $service->addMethod(
178      'pwg.categories.getList',
179      'ws_categories_getList',
180      array(
181        'cat_id' =>       array('default'=>null,
182                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE,
183                                'info'=>'Parent category. "0" or empty for root.'),
184        'recursive' =>    array('default'=>false,
185                                'type'=>WS_TYPE_BOOL),
186        'public' =>       array('default'=>false,
187                                'type'=>WS_TYPE_BOOL),
188        'tree_output' =>  array('default'=>false,
189                                'type'=>WS_TYPE_BOOL),
190        'fullname' =>     array('default'=>false,
191                                'type'=>WS_TYPE_BOOL),
192        ),
193      'Returns a list of categories.'
194    );
195
196  $service->addMethod(
197      'pwg.getMissingDerivatives',
198      'ws_getMissingDerivatives',
199      array_merge(array(
200        'types' =>        array('default'=>null,
201                                'flags'=>WS_PARAM_FORCE_ARRAY,
202                                'info'=>'square, thumb, 2small, xsmall, small, medium, large, xlarge, xxlarge'),
203        'ids' =>          array('default'=>null,
204                                'flags'=>WS_PARAM_FORCE_ARRAY,
205                                'type'=>WS_TYPE_ID),
206        'max_urls' =>     array('default'=>200,
207                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
208        'prev_page' =>    array('default'=>null,
209                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
210        ), $f_params),
211      '<b>Admin only.</b> Returns a list of derivatives to build.',
212      null,
213      array('admin_only'=>true)
214    );
215
216  $service->addMethod(
217      'pwg.images.addComment',
218      'ws_images_addComment',
219      array(
220        'image_id' => array('type'=>WS_TYPE_ID),
221        'author' =>   array('default'=>is_a_guest()?'guest':$user['username']),
222        'content' =>  array(),
223        'key' =>      array(),
224        ),
225      '<b>POST only.</b> Adds a comment to an image.',
226      null,
227      array('post_only'=>true)
228    );
229
230  $service->addMethod(
231      'pwg.images.getInfo',
232      'ws_images_getInfo',
233      array(
234        'image_id' =>           array('type'=>WS_TYPE_ID),
235        'comments_page' =>      array('default'=>0,
236                                      'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
237        'comments_per_page' =>  array('default'=>$conf['nb_comment_page'],
238                                      'maxValue'=>2*$conf['nb_comment_page'],
239                                      'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
240        ),
241      'Returns information about an image.'
242    );
243
244  $service->addMethod(
245      'pwg.images.rate',
246      'ws_images_rate',
247      array(
248        'image_id' => array('type'=>WS_TYPE_ID),
249        'rate' =>     array('type'=>WS_TYPE_FLOAT),
250      ),
251      'Rates an image.'
252    );
253
254  $service->addMethod(
255      'pwg.images.search',
256      'ws_images_search',
257      array_merge(array(
258        'query' =>        array(),
259        'per_page' =>     array('default'=>100,
260                                'maxValue'=>$conf['ws_max_images_per_page'],
261                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
262        'page' =>         array('default'=>0,
263                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
264        'order' =>        array('default'=>null,
265                                'info'=>'id, file, name, hit, rating_score, date_creation, date_available, random'),
266        ), $f_params),
267      'Returns elements for the corresponding query search.'
268    );
269
270  $service->addMethod(
271      'pwg.images.setPrivacyLevel',
272      'ws_images_setPrivacyLevel',
273      array(
274        'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY,
275                            'type'=>WS_TYPE_ID),
276        'level' =>    array('maxValue'=>max($conf['available_permission_levels']),
277                            'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
278        ),
279      '<b>Admin & POST only.</b> Sets the privacy levels for the images.',
280      null,
281      array('admin_only'=>true, 'post_only'=>true)
282    );
283
284  $service->addMethod(
285      'pwg.images.setRank',
286      'ws_images_setRank',
287      array(
288        'image_id'    => array('type'=>WS_TYPE_ID),
289        'category_id' => array('type'=>WS_TYPE_ID),
290        'rank'        => array('type'=>WS_TYPE_INT|WS_TYPE_POSITIVE|WS_TYPE_NOTNULL)
291        ),
292      '<b>Admin & POST only.</b> Sets the rank of a photo for a given album.',
293      null,
294      array('admin_only'=>true, 'post_only'=>true)
295    );
296
297  $service->addMethod(
298      'pwg.rates.delete',
299      'ws_rates_delete',
300      array(
301        'user_id' =>      array('type'=>WS_TYPE_ID),
302        'anonymous_id' => array('default'=>null),
303        ),
304      '<b>Admin & POST only.</b> Deletes all rates for a user.',
305      null,
306      array('admin_only'=>true, 'post_only'=>true)
307    );
308
309  $service->addMethod(
310      'pwg.session.getStatus',
311      'ws_session_getStatus',
312      null,
313      'Gets information about the current session. Also provides a token useable with admin methods.'
314    );
315
316  $service->addMethod(
317      'pwg.session.login',
318      'ws_session_login',
319      array('username', 'password'),
320      '<b>POST only.</b> Tries to login the user.',
321      null,
322      array('post_only'=>true)
323    );
324
325  $service->addMethod(
326      'pwg.session.logout',
327      'ws_session_logout',
328      null,
329      'Ends the current session.'
330    );
331
332  $service->addMethod(
333      'pwg.tags.getList',
334      'ws_tags_getList',
335      array(
336        'sort_by_counter' => array('default'=>false,
337                                   'type'=>WS_TYPE_BOOL),
338        ),
339      'Retrieves a list of available tags.'
340    );
341
342  $service->addMethod(
343      'pwg.tags.getImages',
344      'ws_tags_getImages',
345      array_merge(array(
346        'tag_id' =>       array('default'=>null,
347                                'flags'=>WS_PARAM_FORCE_ARRAY,
348                                'type'=>WS_TYPE_ID),
349        'tag_url_name' => array('default'=>null,
350                                'flags'=>WS_PARAM_FORCE_ARRAY),
351        'tag_name' =>     array('default'=>null,
352                                'flags'=>WS_PARAM_FORCE_ARRAY),
353        'tag_mode_and' => array('default'=>false,
354                                'type'=>WS_TYPE_BOOL),
355        'per_page' =>     array('default'=>100,
356                                'maxValue'=>$conf['ws_max_images_per_page'],
357                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
358        'page' =>         array('default'=>0,
359                                'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
360        'order' =>        array('default'=>null,
361                                'info'=>'id, file, name, hit, rating_score, date_creation, date_available, random'),
362        ), $f_params),
363      'Returns elements for the corresponding tags. Fill at least tag_id, tag_url_name or tag_name.'
364    );
365
366  $service->addMethod(
367      'pwg.images.addChunk',
368      'ws_images_add_chunk',
369      array(
370        'data' =>         array(),
371        'original_sum' => array(),
372        'type' =>         array('default'=>'file',
373                                'info'=>'Must be "file", for backward compatiblity "high" and "thumb" are allowed.'),
374        'position' =>     array()
375        ),
376      '<b>Admin & POST only.</b> Add a chunk of a file.',
377      null,
378      array('admin_only'=>true, 'post_only'=>true)
379    );
380
381  $service->addMethod(
382      'pwg.images.addFile',
383      'ws_images_addFile',
384      array(
385        'image_id' => array('type'=>WS_TYPE_ID),
386        'type' =>     array('default'=>'file',
387                            'info'=>'Must be "file", for backward compatiblity "high" and "thumb" are allowed.'),
388        'sum' =>      array(),
389        ),
390      '<b>Admin only.</b> Add or update a file for an existing photo.
391<br>pwg.images.addChunk must have been called before (maybe several times).',
392      null,
393      array('admin_only'=>true)
394    );
395
396
397  $service->addMethod(
398      'pwg.images.add',
399      'ws_images_add',
400      array(
401        'thumbnail_sum' =>      array('default'=>null),
402        'high_sum' =>           array('default'=>null),
403        'original_sum' =>       array(),
404        'original_filename' =>  array('default'=>null,
405                                      'Provide it if "check_uniqueness" is true and $conf["uniqueness_mode"] is "filename".'),
406        'name' =>               array('default'=>null),
407        'author' =>             array('default'=>null),
408        'date_creation' =>      array('default'=>null),
409        'comment' =>            array('default'=>null),
410        'categories' =>         array('default'=>null,
411                                      'info'=>'String list "category_id[,rank];category_id[,rank]".<br>The rank is optional and is equivalent to "auto" if not given.'),
412        'tag_ids' =>            array('default'=>null,
413                                      'info'=>'Comma separated ids'),
414        'level' =>              array('default'=>0,
415                                      'maxValue'=>max($conf['available_permission_levels']),
416                                      'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
417        'check_uniqueness' =>   array('default'=>true,
418                                      'type'=>WS_TYPE_BOOL),
419        'image_id' =>           array('default'=>null,
420                                      'type'=>WS_TYPE_ID),
421        ),
422      '<b>Admin only.</b> Add an image.
423<br>pwg.images.addChunk must have been called before (maybe several times).
424<br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.',
425      null,
426      array('admin_only'=>true)
427    );
428
429  $service->addMethod(
430      'pwg.images.addSimple',
431      'ws_images_addSimple',
432      array(
433        'category' => array('default'=>null,
434                            'flags'=>WS_PARAM_FORCE_ARRAY,
435                            'type'=>WS_TYPE_ID),
436        'name' =>     array('default'=>null),
437        'author' =>   array('default'=>null),
438        'comment' =>  array('default'=>null),
439        'level' =>    array('default'=>0,
440                            'maxValue'=>max($conf['available_permission_levels']),
441                            'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
442        'tags' =>     array('default'=>null,
443                            'flags'=>WS_PARAM_ACCEPT_ARRAY),
444        'image_id' => array('default'=>null,
445                            'type'=>WS_TYPE_ID),
446        ),
447      '<b>Admin & POST only.</b> Add an image.
448<br>Use the <b>$_FILES[image]</b> field for uploading file.
449<br>Set the form encoding to "form-data".
450<br>You can update an existing photo if you define an existing image_id.',
451      null,
452      array('admin_only'=>true, 'post_only'=>true)
453    );
454
455  $service->addMethod(
456      'pwg.images.delete',
457      'ws_images_delete',
458      array(
459        'image_id' =>   array('flags'=>WS_PARAM_ACCEPT_ARRAY),
460        'pwg_token' =>  array(),
461        ),
462      '<b>Admin & POST only.</b> Deletes image(s).',
463      null,
464      array('admin_only'=>true, 'post_only'=>true)
465    );
466
467  $service->addMethod(
468      'pwg.categories.getAdminList',
469      'ws_categories_getAdminList',
470      null,
471      '<b>Admin only.</b>',
472      null,
473      array('admin_only'=>true)
474    );
475
476  $service->addMethod(
477      'pwg.categories.add',
478      'ws_categories_add',
479      array(
480        'name' =>         array(),
481        'parent' =>       array('default'=>null,
482                                'type'=>WS_TYPE_ID),
483        'comment' =>      array('default'=>null),
484        'visible' =>      array('default'=>true,
485                                'type'=>WS_TYPE_BOOL),
486        'status' =>       array('default'=>null,
487                                'info'=>'public, private'),
488        'commentable' =>  array('default'=>true,
489                                'type'=>WS_TYPE_BOOL),
490        ),
491      '<b>Admin only.</b> Adds an album.'
492    );
493
494  $service->addMethod(
495      'pwg.categories.delete',
496      'ws_categories_delete',
497      array(
498        'category_id'=>           array('flags'=>WS_PARAM_ACCEPT_ARRAY),
499        'photo_deletion_mode' =>  array('default'=>'delete_orphans'),
500        'pwg_token' =>            array(),
501        ),
502      '<b>Admin & POST only.</b> Deletes album(s).
503<br><b>photo_deletion_mode</b> can be "no_delete" (may create orphan photos), "delete_orphans"
504(default mode, only deletes photos linked to no other album) or "force_delete" (delete all photos, even those linked to other albums)',
505      null,
506      array('admin_only'=>true, 'post_only'=>true)
507    );
508
509  $service->addMethod(
510      'pwg.categories.move',
511      'ws_categories_move',
512      array(
513        'category_id' =>  array('flags'=>WS_PARAM_ACCEPT_ARRAY),
514        'parent' =>       array('type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
515        'pwg_token' =>    array(),
516        ),
517      '<b>Admin & POST only.</b> Move album(s).
518<br>Set parent as 0 to move to gallery root. Only virtual categories can be moved.',
519      null,
520      array('admin_only'=>true, 'post_only'=>true)
521    );
522
523  $service->addMethod(
524      'pwg.categories.setRepresentative',
525      'ws_categories_setRepresentative',
526      array(
527        'category_id' =>  array('type'=>WS_TYPE_ID),
528        'image_id' =>     array('type'=>WS_TYPE_ID),
529        ),
530      '<b>Admin & POST only.</b> Sets the representative photo for an album. The photo doesn\'t have to belong to the album.',
531      null,
532      array('admin_only'=>true, 'post_only'=>true)
533    );
534
535  $service->addMethod(
536      'pwg.tags.getAdminList',
537      'ws_tags_getAdminList',
538      null,
539      '<b>Admin only.</b>',
540      null,
541      array('admin_only'=>true)
542    );
543
544  $service->addMethod( // TODO: create multiple tags
545      'pwg.tags.add',
546      'ws_tags_add',
547      array('name'),
548      '<b>Admin only.</b> Adds a new tag.',
549      null,
550      array('admin_only'=>true)
551    );
552
553  $service->addMethod(
554      'pwg.images.exist',
555      'ws_images_exist',
556      array(
557        'md5sum_list' =>    array('default'=>null),
558        'filename_list' =>  array('default'=>null),
559        ),
560      '<b>Admin only.</b>  Checks existence of images.
561<br>Give <b>md5sum_list</b> if $conf[uniqueness_mode]==md5sum. Give <b>filename_list</b> if $conf[uniqueness_mode]==filename.',
562      null,
563      array('admin_only'=>true)
564    );
565
566  $service->addMethod(
567      'pwg.images.checkFiles',
568      'ws_images_checkFiles',
569      array(
570        'image_id' =>       array('type'=>WS_TYPE_ID),
571        'file_sum' =>       array('default'=>null),
572        'thumbnail_sum' =>  array('default'=>null),
573        'high_sum' =>       array('default'=>null),
574        ),
575      '<b>Admin only.</b> Checks if you have updated version of your files for a given photo, the answer can be "missing", "equals" or "differs".
576<br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.',
577      null,
578      array('admin_only'=>true)
579    );
580
581  $service->addMethod(
582      'pwg.images.checkUpload',
583      'ws_images_checkUpload',
584      null,
585      '<b>Admin only.</b> Checks if Piwigo is ready for upload.',
586      null,
587      array('admin_only'=>true)
588    );
589
590  $service->addMethod(
591      'pwg.images.setInfo',
592      'ws_images_setInfo',
593      array(
594        'image_id' =>       array('type'=>WS_TYPE_ID),
595        'file' =>           array('default'=>null),
596        'name' =>           array('default'=>null),
597        'author' =>         array('default'=>null),
598        'date_creation' =>  array('default'=>null),
599        'comment' =>        array('default'=>null),
600        'categories' =>     array('default'=>null,
601                                  'info'=>'String list "category_id[,rank];category_id[,rank]".<br>The rank is optional and is equivalent to "auto" if not given.'),
602        'tag_ids' =>        array('default'=>null,
603                                  'info'=>'Comma separated ids'),
604        'level' =>          array('default'=>null,
605                                  'maxValue'=>max($conf['available_permission_levels']),
606                                  'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
607        'single_value_mode' =>    array('default'=>'fill_if_empty'),
608        'multiple_value_mode' =>  array('default'=>'append'),
609        ),
610      '<b>Admin & POST only.</b> Changes properties of an image.
611<br><b>single_value_mode</b> can be "fill_if_empty" (only use the input value if the corresponding values is currently empty) or "replace"
612(overwrite any existing value) and applies to single values properties like name/author/date_creation/comment.
613<br><b>multiple_value_mode</b> can be "append" (no change on existing values, add the new values) or "replace" and applies to multiple values properties like tag_ids/categories.',
614      null,
615      array('admin_only'=>true, 'post_only'=>true)
616    );
617
618  $service->addMethod(
619      'pwg.categories.setInfo',
620      'ws_categories_setInfo',
621      array(
622        'category_id' =>  array('type'=>WS_TYPE_ID),
623        'name' =>         array('default'=>null),
624        'comment' =>      array('default'=>null),
625        ),
626      '<b>Admin & POST only.</b> Changes properties of an album.',
627      null,
628      array('admin_only'=>true, 'post_only'=>true)
629    );
630 
631  $service->addMethod(
632      'pwg.plugins.getList',
633      'ws_plugins_getList',
634      null,
635      '<b>Admin only.</b> Gets the list of plugins with id, name, version, state and description.',
636      null,
637      array('admin_only'=>true)
638    );
639
640  $service->addMethod(
641      'pwg.plugins.performAction',
642      'ws_plugins_performAction',
643      array(
644        'action'    => array('info'=>'install, activate, deactivate, uninstall, delete'),
645        'plugin'    => array(),
646        'pwg_token' => array(),
647        ),
648      '<b>Admin only.</b>',
649      null,
650      array('admin_only'=>true)
651    );
652
653  $service->addMethod(
654      'pwg.themes.performAction',
655      'ws_themes_performAction',
656      array(
657        'action'    => array('info'=>'activate, deactivate, delete, set_default'),
658        'theme'     => array(),
659        'pwg_token' => array(),
660        ),
661      '<b>Admin only.</b>',
662      null,
663      array('admin_only'=>true)
664    );
665
666  $service->addMethod(
667      'pwg.extensions.update',
668      'ws_extensions_update',
669      array(
670        'type' => array('info'=>'plugins, languages, themes'),
671        'id' => array(),
672        'revision' => array(),
673        'pwg_token' => array(),
674        ),
675      '<b>Webmaster only.</b>',
676      null,
677      array('admin_only'=>true)
678    );
679
680  $service->addMethod(
681      'pwg.extensions.ignoreUpdate',
682      'ws_extensions_ignoreupdate',
683      array(
684        'type' =>       array('default'=>null,
685                              'info'=>'plugins, languages, themes'),
686        'id' =>         array('default'=>null),
687        'reset' =>      array('default'=>false,
688                              'type'=>WS_TYPE_BOOL,
689                              'info'=>'If true, all ignored extensions will be reinitilized.'),
690        'pwg_token' =>  array(),
691      ),
692      '<b>Webmaster only.</b> Ignores an extension if it needs update.',
693      null,
694      array('admin_only'=>true)
695    );
696
697  $service->addMethod(
698      'pwg.extensions.checkUpdates',
699      'ws_extensions_checkupdates',
700      null,
701      '<b>Admin only.</b> Checks if piwigo or extensions are up to date.',
702      null,
703      array('admin_only'=>true)
704    );
705
706  $service->addMethod(
707      'pwg.groups.getList',
708      'ws_groups_getList',
709      array(
710        'group_id' => array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
711                            'type'=>WS_TYPE_ID),
712        'name' =>     array('flags'=>WS_PARAM_OPTIONAL,
713                            'info'=>'Use "%" as wildcard.'),
714        'per_page' => array('default'=>100,
715                            'maxValue'=>$conf['ws_max_users_per_page'],
716                            'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
717        'page' =>     array('default'=>0,
718                            'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
719        'order' =>    array('default'=>'name',
720                            'info'=>'id, name, nb_users, is_default'),
721        ),
722      '<b>Admin only.</b> Retrieves a list of all groups. The list can be filtered.',
723      null,
724      array('admin_only'=>true)
725    );
726
727  $service->addMethod(
728      'pwg.groups.add',
729      'ws_groups_add',
730      array(
731        'name' =>       array(),
732        'is_default' => array('default'=>false,
733                              'type'=>WS_TYPE_BOOL),
734        ),
735      '<b>Admin & POST only.</b> Creates a group and returns the new group record.',
736      null,
737      array('admin_only'=>true, 'post_only'=>true)
738    );
739
740  $service->addMethod(
741      'pwg.groups.delete',
742      'ws_groups_delete',
743      array(
744        'group_id' => array('flags'=>WS_PARAM_FORCE_ARRAY,
745                            'type'=>WS_TYPE_ID),
746        ),
747      '<b>Admin & POST only.</b> Deletes a or more groups. Users and photos are not deleted.',
748      null,
749      array('admin_only'=>true, 'post_only'=>true)
750    );
751
752  $service->addMethod(
753      'pwg.groups.setInfo',
754      'ws_groups_setInfo',
755      array(
756        'group_id' =>   array('type'=>WS_TYPE_ID),
757        'name' =>       array('flags'=>WS_PARAM_OPTIONAL),
758        'is_default' => array('flags'=>WS_PARAM_OPTIONAL,
759                              'type'=>WS_TYPE_BOOL),
760        ),
761      '<b>Admin & POST only.</b> Updates a group. Leave a field blank to keep the current value.',
762      null,
763      array('admin_only'=>true, 'post_only'=>true)
764    );
765
766  $service->addMethod(
767      'pwg.groups.addUser',
768      'ws_groups_addUser',
769      array(
770        'group_id' => array('type'=>WS_TYPE_ID),
771        'user_id' =>  array('flags'=>WS_PARAM_FORCE_ARRAY,
772                            'type'=>WS_TYPE_ID),
773        ),
774      '<b>Admin only.</b> Adds one or more users to a group.',
775      null,
776      array('admin_only'=>true)
777    );
778
779  $service->addMethod(
780      'pwg.groups.deleteUser',
781      'ws_groups_deleteUser',
782      array(
783        'group_id' => array('type'=>WS_TYPE_ID),
784        'user_id' =>  array('flags'=>WS_PARAM_FORCE_ARRAY,
785                            'type'=>WS_TYPE_ID),
786        ),
787      '<b>Admin & POST only.</b> Removes one or more users from a group.',
788      null,
789      array('admin_only'=>true, 'post_only'=>true)
790    );
791
792  $service->addMethod(
793      'pwg.users.getList',
794      'ws_users_getList',
795      array(
796        'user_id' =>    array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
797                              'type'=>WS_TYPE_ID),
798        'username' =>   array('flags'=>WS_PARAM_OPTIONAL,
799                              'info'=>'Use "%" as wildcard.'),
800        'status' =>     array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
801                              'info'=>'guest,generic,normal,admin,webmaster'),
802        'min_level' =>  array('default'=>0,
803                              'maxValue'=>max($conf['available_permission_levels']),
804                              'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
805        'group_id' =>   array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
806                              'type'=>WS_TYPE_ID),
807        'per_page' =>   array('default'=>100,
808                              'maxValue'=>$conf['ws_max_users_per_page'],
809                              'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
810        'page' =>       array('default'=>0,
811                              'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
812        'order' =>      array('default'=>'id',
813                              'info'=>'id, username, level, email'),
814        'display' =>    array('default'=>'basics',
815                              'info'=>'all,basics,none,username,email,status,level,groups,language,theme,nb_image_page,recent_period,expand,show_nb_comments,show_nb_hits,enabled_high'),
816        ),
817      '<b>Admin only.</b> Retrieves a list of all the users.
818<br>"display" controls which data are returned, "basics" stands for "username,email,status,level,groups"',
819      null,
820      array('admin_only'=>true)
821    );
822
823  $service->addMethod(
824      'pwg.users.add',
825      'ws_users_add',
826      array(
827        'username' => array(),
828        'password' => array('default'=>null),
829        'email' =>    array('default'=>null),
830        ),
831      '<b>Admin & POST only.</b> Registers a new user.',
832      null,
833      array('admin_only'=>true, 'post_only'=>true)
834    );
835
836  $service->addMethod(
837      'pwg.users.delete',
838      'ws_users_delete',
839      array(
840        'user_id' =>  array('flags'=>WS_PARAM_FORCE_ARRAY,
841                            'type'=>WS_TYPE_ID),
842        ),
843      '<b>Admin & POST only.</b> Deletes on or more users. Photos owned by this user are not deleted.',
844      null,
845      array('admin_only'=>true, 'post_only'=>true)
846    );
847
848  $service->addMethod(
849      'pwg.users.setInfo',
850      'ws_users_setInfo',
851      array(
852        'user_id' =>          array('flags'=>WS_PARAM_FORCE_ARRAY,
853                                    'type'=>WS_TYPE_ID),
854        'username' =>         array('flags'=>WS_PARAM_OPTIONAL),
855        'password' =>         array('flags'=>WS_PARAM_OPTIONAL),
856        'email' =>            array('flags'=>WS_PARAM_OPTIONAL),
857        'status' =>           array('flags'=>WS_PARAM_OPTIONAL,
858                                    'info'=>'guest,generic,normal,admin,webmaster'),
859        'level'=>             array('flags'=>WS_PARAM_OPTIONAL,
860                                    'maxValue'=>max($conf['available_permission_levels']),
861                                    'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
862        'language' =>         array('flags'=>WS_PARAM_OPTIONAL),
863        'theme' =>            array('flags'=>WS_PARAM_OPTIONAL),
864        // bellow are parameters removed in a future version
865        'nb_image_page' =>    array('flags'=>WS_PARAM_OPTIONAL,
866                                    'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE|WS_TYPE_NOTNULL),
867        'recent_period' =>    array('flags'=>WS_PARAM_OPTIONAL,
868                                    'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
869        'expand' =>           array('flags'=>WS_PARAM_OPTIONAL,
870                                    'type'=>WS_TYPE_BOOL),
871        'show_nb_comments' => array('flags'=>WS_PARAM_OPTIONAL,
872                                    'type'=>WS_TYPE_BOOL),
873        'show_nb_hits' =>     array('flags'=>WS_PARAM_OPTIONAL,
874                                    'type'=>WS_TYPE_BOOL),
875        'enabled_high' =>     array('flags'=>WS_PARAM_OPTIONAL,
876                                    'type'=>WS_TYPE_BOOL),
877        ),
878      '<b>Admin & POST only.</b> Updates a user. Leave a field blank to keep the current value.
879<br>"username", "password" and "email" are ignored if "user_id" is an array.',
880      null,
881      array('admin_only'=>true, 'post_only'=>true)
882    );
883}
884
885?>
Note: See TracBrowser for help on using the repository browser.