source: trunk/ws.php @ 25184

Last change on this file since 25184 was 25118, checked in by mistic100, 11 years ago

feature 2976: can change user status and level
fix saving problem of groups.is_default value
use WS_PARAM_OPTIONAL when possible (TODO: use for old methods)

  • Property svn:eol-style set to LF
File size: 30.8 KB
RevLine 
[1698]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[19703]5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[1698]23
24define ('PHPWG_ROOT_PATH', './');
25
26include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
[2325]27check_status(ACCESS_FREE);
[1698]28include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php');
29
[1781]30if ( !$conf['allow_web_services'] )
31{
32  page_forbidden('Web services are disabled');
33}
34
[20815]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
[1768]96/**
97 * event handler that registers standard methods with the web service
98 */
[1698]99function ws_addDefaultMethods( $arr )
100{
[1849]101  global $conf, $user;
[1698]102  $service = &$arr[0];
[20815]103 
104  include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php');
105 
[25077]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 
[20817]127  $service->addMethod(
128      'pwg.getVersion',
129      'ws_getVersion',
[20815]130      null,
[25077]131      'Returns the Piwigo version.'
[20815]132    );
[10017]133         
[20817]134  $service->addMethod(
135      'pwg.getInfos',
136      'ws_getInfos',
[20815]137      null,
[25115]138      '<b>Admin only.</b> Returns general informations.',
139      null,
140      array('admin_only'=>true)
[20815]141    );
[1698]142
[20817]143  $service->addMethod(
144      'pwg.caddie.add',
145      'ws_caddie_add',
[2429]146      array(
[25077]147        'image_id'=> array('flags'=>WS_PARAM_FORCE_ARRAY,
148                           'type'=>WS_TYPE_ID),
[20815]149        ),
[25115]150      '<b>Admin only.</b> Adds elements to the caddie. Returns the number of elements added.',
151      null,
152      array('admin_only'=>true)
[20815]153    );
[2429]154
[20817]155  $service->addMethod(
156      'pwg.categories.getImages',
157      'ws_categories_getImages',
[25077]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),
[1698]172      'Returns elements for the corresponding categories.
[25077]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'
[1698]175    );
176
[20817]177  $service->addMethod(
178      'pwg.categories.getList',
179      'ws_categories_getList',
[1698]180      array(
[25077]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),
[20815]192        ),
[25077]193      'Returns a list of categories.'
[20815]194    );
[1698]195
[20817]196  $service->addMethod(
197      'pwg.getMissingDerivatives',
198      'ws_getMissingDerivatives',
[25077]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),
[25115]211      '<b>Admin only.</b> Returns a list of derivatives to build.',
212      null,
213      array('admin_only'=>true)
[20815]214    );
[12865]215
[20817]216  $service->addMethod(
217      'pwg.images.addComment',
218      'ws_images_addComment',
[1849]219      array(
[25077]220        'image_id' => array('type'=>WS_TYPE_ID),
[20815]221        'author' =>   array('default'=>is_a_guest()?'guest':$user['username']),
222        'content' =>  array(),
223        'key' =>      array(),
224        ),
[25115]225      '<b>POST only.</b> Adds a comment to an image.',
226      null,
227      array('post_only'=>true)
[20815]228    );
[1849]229
[20817]230  $service->addMethod(
231      'pwg.images.getInfo',
232      'ws_images_getInfo',
[1849]233      array(
[25077]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),
[20815]240        ),
[25077]241      'Returns information about an image.'
[20815]242    );
[1698]243
[20817]244  $service->addMethod(
245      'pwg.images.rate',
246      'ws_images_rate',
[25077]247      array(
248        'image_id' => array('type'=>WS_TYPE_ID),
249        'rate' =>     array('type'=>WS_TYPE_FLOAT),
250      ),
251      'Rates an image.'
[20815]252    );
[2435]253
[20817]254  $service->addMethod(
255      'pwg.images.search',
256      'ws_images_search',
[25077]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),
[1837]267      'Returns elements for the corresponding query search.'
268    );
[2516]269
[20817]270  $service->addMethod(
271      'pwg.images.setPrivacyLevel',
272      'ws_images_setPrivacyLevel',
[20815]273      array(
[25077]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),
[20815]278        ),
[25115]279      '<b>Admin & POST only.</b> Sets the privacy levels for the images.',
280      null,
281      array('admin_only'=>true, 'post_only'=>true)
[2463]282    );
[1837]283
[20817]284  $service->addMethod(
285      'pwg.images.setRank',
286      'ws_images_setRank',
[25077]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        ),
[25115]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)
[11372]295    );
[12624]296
[20817]297  $service->addMethod(
298      'pwg.rates.delete',
299      'ws_rates_delete',
[20815]300      array(
[25077]301        'user_id' =>      array('type'=>WS_TYPE_ID),
[20815]302        'anonymous_id' => array('default'=>null),
303        ),
[25115]304      '<b>Admin & POST only.</b> Deletes all rates for a user.',
305      null,
306      array('admin_only'=>true, 'post_only'=>true)
[12624]307    );
[20815]308
[20817]309  $service->addMethod(
310      'pwg.session.getStatus',
311      'ws_session_getStatus',
312      null,
[25077]313      'Gets information about the current session. Also provides a token useable with admin methods.'
[20817]314    );
[20815]315
[20817]316  $service->addMethod(
317      'pwg.session.login',
318      'ws_session_login',
[20815]319      array('username', 'password'),
[25115]320      '<b>POST only.</b> Tries to login the user.',
321      null,
322      array('post_only'=>true)
[20815]323    );
324
[20817]325  $service->addMethod(
326      'pwg.session.logout',
327      'ws_session_logout',
328      null,
[25077]329      'Ends the current session.'
[20817]330    );
[1698]331
[20817]332  $service->addMethod(
333      'pwg.tags.getList',
334      'ws_tags_getList',
[20815]335      array(
[25077]336        'sort_by_counter' => array('default'=>false,
337                                   'type'=>WS_TYPE_BOOL),
[20815]338        ),
[25077]339      'Retrieves a list of available tags.'
[20815]340    );
341
[20817]342  $service->addMethod(
343      'pwg.tags.getImages',
344      'ws_tags_getImages',
[25077]345      array_merge(array(
[20815]346        'tag_id' =>       array('default'=>null,
[25077]347                                'flags'=>WS_PARAM_FORCE_ARRAY,
348                                'type'=>WS_TYPE_ID),
[20815]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),
[25077]353        'tag_mode_and' => array('default'=>false,
354                                'type'=>WS_TYPE_BOOL),
[20815]355        'per_page' =>     array('default'=>100,
[25077]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.'
[1698]364    );
[2463]365
[20817]366  $service->addMethod(
367      'pwg.images.addChunk',
368      'ws_images_add_chunk',
[25077]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        ),
[25115]376      '<b>Admin & POST only.</b> Add a chunk of a file.',
377      null,
378      array('admin_only'=>true, 'post_only'=>true)
[3193]379    );
380
[20817]381  $service->addMethod(
382      'pwg.images.addFile',
383      'ws_images_addFile',
[25077]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.
[25115]391<br>pwg.images.addChunk must have been called before (maybe several times).',
392      null,
393      array('admin_only'=>true)
[4348]394    );
395
396
[20817]397  $service->addMethod(
398      'pwg.images.add',
399      'ws_images_add',
[20815]400      array(
401        'thumbnail_sum' =>      array('default'=>null),
402        'high_sum' =>           array('default'=>null),
403        'original_sum' =>       array(),
[25077]404        'original_filename' =>  array('default'=>null,
405                                      'Provide it if "check_uniqueness" is true and $conf["uniqueness_mode"] is "filename".'),
[20815]406        'name' =>               array('default'=>null),
407        'author' =>             array('default'=>null),
408        'date_creation' =>      array('default'=>null),
409        'comment' =>            array('default'=>null),
[25077]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'),
[20815]414        'level' =>              array('default'=>0,
[25077]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),
[2569]421        ),
[25077]422      '<b>Admin only.</b> Add an image.
423<br>pwg.images.addChunk must have been called before (maybe several times).
[25115]424<br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.',
425      null,
426      array('admin_only'=>true)
[2463]427    );
[2563]428
[20817]429  $service->addMethod(
430      'pwg.images.addSimple',
431      'ws_images_addSimple',
[20815]432      array(
[25077]433        'category' => array('default'=>null,
434                            'flags'=>WS_PARAM_FORCE_ARRAY,
435                            'type'=>WS_TYPE_ID),
[20815]436        'name' =>     array('default'=>null),
437        'author' =>   array('default'=>null),
438        'comment' =>  array('default'=>null),
439        'level' =>    array('default'=>0,
[25077]440                            'maxValue'=>max($conf['available_permission_levels']),
441                            'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
[20815]442        'tags' =>     array('default'=>null,
443                            'flags'=>WS_PARAM_ACCEPT_ARRAY),
[25077]444        'image_id' => array('default'=>null,
445                            'type'=>WS_TYPE_ID),
[8249]446        ),
[25077]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".
[25115]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)
[8249]453    );
[8266]454
[20817]455  $service->addMethod(
456      'pwg.images.delete',
457      'ws_images_delete',
[20815]458      array(
[25077]459        'image_id' =>   array('flags'=>WS_PARAM_ACCEPT_ARRAY),
[20815]460        'pwg_token' =>  array(),
461        ),
[25115]462      '<b>Admin & POST only.</b> Deletes image(s).',
463      null,
464      array('admin_only'=>true, 'post_only'=>true)
[8266]465    );
466
[20817]467  $service->addMethod(
468      'pwg.categories.getAdminList',
469      'ws_categories_getAdminList',
[20815]470      null,
[25115]471      '<b>Admin only.</b>',
472      null,
473      array('admin_only'=>true)
[2563]474    );
[2583]475
[20817]476  $service->addMethod(
477      'pwg.categories.add',
478      'ws_categories_add',
[20815]479      array(
480        'name' =>         array(),
[25077]481        'parent' =>       array('default'=>null,
482                                'type'=>WS_TYPE_ID),
[20815]483        'comment' =>      array('default'=>null),
[25077]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),
[20815]490        ),
[25077]491      '<b>Admin only.</b> Adds an album.'
[2583]492    );
[2584]493
[20817]494  $service->addMethod(
495      'pwg.categories.delete',
496      'ws_categories_delete',
[20815]497      array(
[25077]498        'category_id'=>           array('flags'=>WS_PARAM_ACCEPT_ARRAY),
499        'photo_deletion_mode' =>  array('default'=>'delete_orphans'),
[20815]500        'pwg_token' =>            array(),
501        ),
[25077]502      '<b>Admin & POST only.</b> Deletes album(s).
[20815]503<br><b>photo_deletion_mode</b> can be "no_delete" (may create orphan photos), "delete_orphans"
[25115]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)
[8266]507    );
508
[20817]509  $service->addMethod(
510      'pwg.categories.move',
511      'ws_categories_move',
[20815]512      array(
[25077]513        'category_id' =>  array('flags'=>WS_PARAM_ACCEPT_ARRAY),
514        'parent' =>       array('type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
[20815]515        'pwg_token' =>    array(),
516        ),
[25077]517      '<b>Admin & POST only.</b> Move album(s).
[25115]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)
[8272]521    );
[11746]522
[20817]523  $service->addMethod(
524      'pwg.categories.setRepresentative',
525      'ws_categories_setRepresentative',
[20815]526      array(
[25077]527        'category_id' =>  array('type'=>WS_TYPE_ID),
528        'image_id' =>     array('type'=>WS_TYPE_ID),
[20815]529        ),
[25115]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)
[11746]533    );
534
[20817]535  $service->addMethod(
536      'pwg.tags.getAdminList',
537      'ws_tags_getAdminList',
[20815]538      null,
[25115]539      '<b>Admin only.</b>',
540      null,
541      array('admin_only'=>true)
[2584]542    );
[2634]543
[25077]544  $service->addMethod( // TODO: create multiple tags
[20817]545      'pwg.tags.add',
546      'ws_tags_add',
[20815]547      array('name'),
[25115]548      '<b>Admin only.</b> Adds a new tag.',
549      null,
550      array('admin_only'=>true)
[2634]551    );
[2683]552
[20817]553  $service->addMethod(
554      'pwg.images.exist',
555      'ws_images_exist',
[20815]556      array(
557        'md5sum_list' =>    array('default'=>null),
558        'filename_list' =>  array('default'=>null),
559        ),
[25077]560      '<b>Admin only.</b>  Checks existence of images.
[25115]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)
[2683]564    );
[2919]565
[20817]566  $service->addMethod(
567      'pwg.images.checkFiles',
568      'ws_images_checkFiles',
[20815]569      array(
[25077]570        'image_id' =>       array('type'=>WS_TYPE_ID),
571        'file_sum' =>       array('default'=>null),
[20815]572        'thumbnail_sum' =>  array('default'=>null),
573        'high_sum' =>       array('default'=>null),
574        ),
[25077]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".
[25115]576<br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.',
577      null,
578      array('admin_only'=>true)
[4347]579    );
580
[20817]581  $service->addMethod(
582      'pwg.images.checkUpload',
583      'ws_images_checkUpload',
[20815]584      null,
[25115]585      '<b>Admin only.</b> Checks if Piwigo is ready for upload.',
586      null,
587      array('admin_only'=>true)
[6049]588    );
589
[20817]590  $service->addMethod(
591      'pwg.images.setInfo',
592      'ws_images_setInfo',
[20815]593      array(
[25077]594        'image_id' =>       array('type'=>WS_TYPE_ID),
[20815]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),
[25077]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'),
[20815]604        'level' =>          array('default'=>null,
[25077]605                                  'maxValue'=>max($conf['available_permission_levels']),
606                                  'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
[20815]607        'single_value_mode' =>    array('default'=>'fill_if_empty'),
608        'multiple_value_mode' =>  array('default'=>'append'),
[2919]609        ),
[25077]610      '<b>Admin & POST only.</b> Changes properties of an image.
[20815]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"
[25077]612(overwrite any existing value) and applies to single values properties like name/author/date_creation/comment.
[25115]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)
[2919]616    );
[4513]617
[20817]618  $service->addMethod(
619      'pwg.categories.setInfo',
620      'ws_categories_setInfo',
[20815]621      array(
[25077]622        'category_id' =>  array('type'=>WS_TYPE_ID),
[20815]623        'name' =>         array('default'=>null),
624        'comment' =>      array('default'=>null),
625        ),
[25115]626      '<b>Admin & POST only.</b> Changes properties of an album.',
627      null,
628      array('admin_only'=>true, 'post_only'=>true)
[3454]629    );
[8273]630 
[20817]631  $service->addMethod(
632      'pwg.plugins.getList',
633      'ws_plugins_getList',
[20815]634      null,
[25115]635      '<b>Admin only.</b> Gets the list of plugins with id, name, version, state and description.',
636      null,
637      array('admin_only'=>true)
[8273]638    );
639
[20817]640  $service->addMethod(
641      'pwg.plugins.performAction',
642      'ws_plugins_performAction',
[25077]643      array(
644        'action'    => array('info'=>'install, activate, deactivate, uninstall, delete'),
645        'plugin'    => array(),
646        'pwg_token' => array(),
647        ),
[25115]648      '<b>Admin only.</b>',
649      null,
650      array('admin_only'=>true)
[8273]651    );
[8309]652
[20817]653  $service->addMethod(
654      'pwg.themes.performAction',
655      'ws_themes_performAction',
[25077]656      array(
657        'action'    => array('info'=>'activate, deactivate, delete, set_default'),
658        'theme'     => array(),
659        'pwg_token' => array(),
660        ),
[25115]661      '<b>Admin only.</b>',
662      null,
663      array('admin_only'=>true)
[8309]664    );
[10235]665
[20817]666  $service->addMethod(
667      'pwg.extensions.update',
668      'ws_extensions_update',
[25077]669      array(
670        'type' => array('info'=>'plugins, languages, themes'),
671        'id' => array(),
672        'revision' => array(),
673        'pwg_token' => array(),
674        ),
[25115]675      '<b>Webmaster only.</b>',
676      null,
677      array('admin_only'=>true)
[25117]678    );
[10511]679
[20817]680  $service->addMethod(
681      'pwg.extensions.ignoreUpdate',
682      'ws_extensions_ignoreupdate',
[20815]683      array(
[25077]684        'type' =>       array('default'=>null,
685                              'info'=>'plugins, languages, themes'),
[20815]686        'id' =>         array('default'=>null),
[25077]687        'reset' =>      array('default'=>false,
688                              'type'=>WS_TYPE_BOOL,
689                              'info'=>'If true, all ignored extensions will be reinitilized.'),
[20815]690        'pwg_token' =>  array(),
691      ),
[25115]692      '<b>Webmaster only.</b> Ignores an extension if it needs update.',
693      null,
694      array('admin_only'=>true)
[25117]695    );
[10538]696
[20817]697  $service->addMethod(
698      'pwg.extensions.checkUpdates',
699      'ws_extensions_checkupdates',
[20815]700      null,
[25115]701      '<b>Admin only.</b> Checks if piwigo or extensions are up to date.',
702      null,
703      array('admin_only'=>true)
[25117]704    );
705
706  $service->addMethod(
707      'pwg.groups.getList',
708      'ws_groups_getList',
709      array(
[25118]710        'group_id' => array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
[25117]711                            'type'=>WS_TYPE_ID),
[25118]712        'name' =>     array('flags'=>WS_PARAM_OPTIONAL,
[25117]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),
[25118]757        'name' =>       array('flags'=>WS_PARAM_OPTIONAL),
758        'is_default' => array('flags'=>WS_PARAM_OPTIONAL,
[25117]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(
[25118]796        'user_id' =>    array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
[25117]797                              'type'=>WS_TYPE_ID),
[25118]798        'username' =>   array('flags'=>WS_PARAM_OPTIONAL,
[25117]799                              'info'=>'Use "%" as wildcard.'),
[25118]800        'status' =>     array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
[25117]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),
[25118]805        'group_id' =>   array('flags'=>WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,
[25117]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        ),
815      '<b>Admin only.</b> Retrieves a list of all the users.',
816      null,
817      array('admin_only'=>true)
818    );
819
820  $service->addMethod(
821      'pwg.users.add',
822      'ws_users_add',
823      array(
824        'username' => array(),
825        'password' => array('default'=>null),
826        'email' =>    array('default'=>null),
827        ),
828      '<b>Admin & POST only.</b> Registers a new user.',
829      null,
830      array('admin_only'=>true, 'post_only'=>true)
831    );
832
833  $service->addMethod(
834      'pwg.users.delete',
835      'ws_users_delete',
836      array(
837        'user_id' =>  array('flags'=>WS_PARAM_FORCE_ARRAY,
838                            'type'=>WS_TYPE_ID),
839        ),
840      '<b>Admin & POST only.</b> Deletes on or more users. Photos owned by this user are not deleted.',
841      null,
842      array('admin_only'=>true, 'post_only'=>true)
843    );
844
845  $service->addMethod(
846      'pwg.users.setInfo',
847      'ws_users_setInfo',
848      array(
849        'user_id' =>  array('type'=>WS_TYPE_ID),
[25118]850        'username' => array('flags'=>WS_PARAM_OPTIONAL),
851        'password' => array('flags'=>WS_PARAM_OPTIONAL),
852        'email' =>    array('flags'=>WS_PARAM_OPTIONAL),
853        'status' =>   array('flags'=>WS_PARAM_OPTIONAL,
854                            'info'=>'generic,normal,admin'),
855        'level'=>     array('flags'=>WS_PARAM_OPTIONAL,
856                            'maxValue'=>max($conf['available_permission_levels']),
857                            'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
[25117]858        ),
859      '<b>Admin & POST only.</b> Updates a user. Leave a field blank to keep the current value.',
860      null,
861      array('admin_only'=>true, 'post_only'=>true)
862    );
[1698]863}
864
[25077]865?>
Note: See TracBrowser for help on using the repository browser.