source: trunk/ws.php @ 27572

Last change on this file since 27572 was 26837, checked in by rvelices, 10 years ago

admin rating improvements

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