source: trunk/ws.php @ 26007

Last change on this file since 26007 was 25474, checked in by plg, 11 years ago

feature 2976: ability to set group association with pwg.users.setInfo

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