1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | define ('PHPWG_ROOT_PATH', './'); |
---|
25 | |
---|
26 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
27 | check_status(ACCESS_FREE); |
---|
28 | include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php'); |
---|
29 | |
---|
30 | if ( !$conf['allow_web_services'] ) |
---|
31 | { |
---|
32 | page_forbidden('Web services are disabled'); |
---|
33 | } |
---|
34 | |
---|
35 | add_event_handler('ws_add_methods', 'ws_addDefaultMethods'); |
---|
36 | |
---|
37 | add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
38 | |
---|
39 | $requestFormat = 'rest'; |
---|
40 | $responseFormat = null; |
---|
41 | |
---|
42 | if ( isset($_GET['format']) ) |
---|
43 | { |
---|
44 | $responseFormat = $_GET['format']; |
---|
45 | } |
---|
46 | |
---|
47 | if ( !isset($responseFormat) and isset($requestFormat) ) |
---|
48 | { |
---|
49 | $responseFormat = $requestFormat; |
---|
50 | } |
---|
51 | |
---|
52 | $service = new PwgServer(); |
---|
53 | |
---|
54 | if (!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 | |
---|
67 | if (!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 | |
---|
92 | set_make_full_url(); |
---|
93 | $service->run(); |
---|
94 | |
---|
95 | |
---|
96 | /** |
---|
97 | * event handler that registers standard methods with the web service |
---|
98 | */ |
---|
99 | function ws_addDefaultMethods( $arr ) |
---|
100 | { |
---|
101 | global $conf, $user; |
---|
102 | $service = &$arr[0]; |
---|
103 | |
---|
104 | include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php'); |
---|
105 | |
---|
106 | $f_params = array( |
---|
107 | 'f_min_rate' => array('default'=>null, |
---|
108 | 'type'=>WS_TYPE_FLOAT), |
---|
109 | 'f_max_rate' => array('default'=>null, |
---|
110 | 'type'=>WS_TYPE_FLOAT), |
---|
111 | 'f_min_hit' => array('default'=>null, |
---|
112 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
113 | 'f_max_hit' => array('default'=>null, |
---|
114 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
115 | 'f_min_ratio' => array('default'=>null, |
---|
116 | 'type'=>WS_TYPE_FLOAT|WS_TYPE_POSITIVE), |
---|
117 | 'f_max_ratio' => array('default'=>null, |
---|
118 | 'type'=>WS_TYPE_FLOAT|WS_TYPE_POSITIVE), |
---|
119 | 'f_max_level' => array('default'=>null, |
---|
120 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
121 | 'f_min_date_available' => array('default'=>null), |
---|
122 | 'f_max_date_available' => array('default'=>null), |
---|
123 | 'f_min_date_created' => array('default'=>null), |
---|
124 | 'f_max_date_created' => array('default'=>null), |
---|
125 | ); |
---|
126 | |
---|
127 | $service->addMethod( |
---|
128 | 'pwg.getVersion', |
---|
129 | 'ws_getVersion', |
---|
130 | null, |
---|
131 | 'Returns the Piwigo version.' |
---|
132 | ); |
---|
133 | |
---|
134 | $service->addMethod( |
---|
135 | 'pwg.getInfos', |
---|
136 | 'ws_getInfos', |
---|
137 | null, |
---|
138 | '<b>Admin only.</b> Returns general informations.' |
---|
139 | ); |
---|
140 | |
---|
141 | $service->addMethod( |
---|
142 | 'pwg.caddie.add', |
---|
143 | 'ws_caddie_add', |
---|
144 | array( |
---|
145 | 'image_id'=> array('flags'=>WS_PARAM_FORCE_ARRAY, |
---|
146 | 'type'=>WS_TYPE_ID), |
---|
147 | ), |
---|
148 | '<b>Admin only.</b> Adds elements to the caddie. Returns the number of elements added.' |
---|
149 | ); |
---|
150 | |
---|
151 | $service->addMethod( |
---|
152 | 'pwg.categories.getImages', |
---|
153 | 'ws_categories_getImages', |
---|
154 | array_merge(array( |
---|
155 | 'cat_id' => array('default'=>null, |
---|
156 | 'flags'=>WS_PARAM_FORCE_ARRAY, |
---|
157 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
158 | 'recursive' => array('default'=>false, |
---|
159 | 'type'=>WS_TYPE_BOOL), |
---|
160 | 'per_page' => array('default'=>100, |
---|
161 | 'maxValue'=>$conf['ws_max_images_per_page'], |
---|
162 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
163 | 'page' => array('default'=>0, |
---|
164 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
165 | 'order' => array('default'=>null, |
---|
166 | 'info'=>'id, file, name, hit, rating_score, date_creation, date_available, random'), |
---|
167 | ), $f_params), |
---|
168 | 'Returns elements for the corresponding categories. |
---|
169 | <br><b>cat_id</b> can be empty if <b>recursive</b> is true. |
---|
170 | <br><b>order</b> comma separated fields for sorting' |
---|
171 | ); |
---|
172 | |
---|
173 | $service->addMethod( |
---|
174 | 'pwg.categories.getList', |
---|
175 | 'ws_categories_getList', |
---|
176 | array( |
---|
177 | 'cat_id' => array('default'=>null, |
---|
178 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE, |
---|
179 | 'info'=>'Parent category. "0" or empty for root.'), |
---|
180 | 'recursive' => array('default'=>false, |
---|
181 | 'type'=>WS_TYPE_BOOL), |
---|
182 | 'public' => array('default'=>false, |
---|
183 | 'type'=>WS_TYPE_BOOL), |
---|
184 | 'tree_output' => array('default'=>false, |
---|
185 | 'type'=>WS_TYPE_BOOL), |
---|
186 | 'fullname' => array('default'=>false, |
---|
187 | 'type'=>WS_TYPE_BOOL), |
---|
188 | ), |
---|
189 | 'Returns a list of categories.' |
---|
190 | ); |
---|
191 | |
---|
192 | $service->addMethod( |
---|
193 | 'pwg.getMissingDerivatives', |
---|
194 | 'ws_getMissingDerivatives', |
---|
195 | array_merge(array( |
---|
196 | 'types' => array('default'=>null, |
---|
197 | 'flags'=>WS_PARAM_FORCE_ARRAY, |
---|
198 | 'info'=>'square, thumb, 2small, xsmall, small, medium, large, xlarge, xxlarge'), |
---|
199 | 'ids' => array('default'=>null, |
---|
200 | 'flags'=>WS_PARAM_FORCE_ARRAY, |
---|
201 | 'type'=>WS_TYPE_ID), |
---|
202 | 'max_urls' => array('default'=>200, |
---|
203 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
204 | 'prev_page' => array('default'=>null, |
---|
205 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
206 | ), $f_params), |
---|
207 | '<b>Admin only.</b> Returns a list of derivatives to build.' |
---|
208 | ); |
---|
209 | |
---|
210 | $service->addMethod( |
---|
211 | 'pwg.images.addComment', |
---|
212 | 'ws_images_addComment', |
---|
213 | array( |
---|
214 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
215 | 'author' => array('default'=>is_a_guest()?'guest':$user['username']), |
---|
216 | 'content' => array(), |
---|
217 | 'key' => array(), |
---|
218 | ), |
---|
219 | '<b>POST only.</b> Adds a comment to an image.' |
---|
220 | ); |
---|
221 | |
---|
222 | $service->addMethod( |
---|
223 | 'pwg.images.getInfo', |
---|
224 | 'ws_images_getInfo', |
---|
225 | array( |
---|
226 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
227 | 'comments_page' => array('default'=>0, |
---|
228 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
229 | 'comments_per_page' => array('default'=>$conf['nb_comment_page'], |
---|
230 | 'maxValue'=>2*$conf['nb_comment_page'], |
---|
231 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
232 | ), |
---|
233 | 'Returns information about an image.' |
---|
234 | ); |
---|
235 | |
---|
236 | $service->addMethod( |
---|
237 | 'pwg.images.rate', |
---|
238 | 'ws_images_rate', |
---|
239 | array( |
---|
240 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
241 | 'rate' => array('type'=>WS_TYPE_FLOAT), |
---|
242 | ), |
---|
243 | 'Rates an image.' |
---|
244 | ); |
---|
245 | |
---|
246 | $service->addMethod( |
---|
247 | 'pwg.images.search', |
---|
248 | 'ws_images_search', |
---|
249 | array_merge(array( |
---|
250 | 'query' => array(), |
---|
251 | 'per_page' => array('default'=>100, |
---|
252 | 'maxValue'=>$conf['ws_max_images_per_page'], |
---|
253 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
254 | 'page' => array('default'=>0, |
---|
255 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
256 | 'order' => array('default'=>null, |
---|
257 | 'info'=>'id, file, name, hit, rating_score, date_creation, date_available, random'), |
---|
258 | ), $f_params), |
---|
259 | 'Returns elements for the corresponding query search.' |
---|
260 | ); |
---|
261 | |
---|
262 | $service->addMethod( |
---|
263 | 'pwg.images.setPrivacyLevel', |
---|
264 | 'ws_images_setPrivacyLevel', |
---|
265 | array( |
---|
266 | 'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY, |
---|
267 | 'type'=>WS_TYPE_ID), |
---|
268 | 'level' => array('maxValue'=>max($conf['available_permission_levels']), |
---|
269 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
270 | ), |
---|
271 | '<b>Admin & POST only.</b> Sets the privacy levels for the images.' |
---|
272 | ); |
---|
273 | |
---|
274 | $service->addMethod( |
---|
275 | 'pwg.images.setRank', |
---|
276 | 'ws_images_setRank', |
---|
277 | array( |
---|
278 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
279 | 'category_id' => array('type'=>WS_TYPE_ID), |
---|
280 | 'rank' => array('type'=>WS_TYPE_INT|WS_TYPE_POSITIVE|WS_TYPE_NOTNULL) |
---|
281 | ), |
---|
282 | '<b>Admin & POST only.</b> Sets the rank of a photo for a given album.' |
---|
283 | ); |
---|
284 | |
---|
285 | $service->addMethod( |
---|
286 | 'pwg.rates.delete', |
---|
287 | 'ws_rates_delete', |
---|
288 | array( |
---|
289 | 'user_id' => array('type'=>WS_TYPE_ID), |
---|
290 | 'anonymous_id' => array('default'=>null), |
---|
291 | ), |
---|
292 | '<b>Admin & POST only.</b> Deletes all rates for a user.' |
---|
293 | ); |
---|
294 | |
---|
295 | $service->addMethod( |
---|
296 | 'pwg.session.getStatus', |
---|
297 | 'ws_session_getStatus', |
---|
298 | null, |
---|
299 | 'Gets information about the current session. Also provides a token useable with admin methods.' |
---|
300 | ); |
---|
301 | |
---|
302 | $service->addMethod( |
---|
303 | 'pwg.session.login', |
---|
304 | 'ws_session_login', |
---|
305 | array('username', 'password'), |
---|
306 | '<b>POST only.</b> Tries to login the user.' |
---|
307 | ); |
---|
308 | |
---|
309 | $service->addMethod( |
---|
310 | 'pwg.session.logout', |
---|
311 | 'ws_session_logout', |
---|
312 | null, |
---|
313 | 'Ends the current session.' |
---|
314 | ); |
---|
315 | |
---|
316 | $service->addMethod( |
---|
317 | 'pwg.tags.getList', |
---|
318 | 'ws_tags_getList', |
---|
319 | array( |
---|
320 | 'sort_by_counter' => array('default'=>false, |
---|
321 | 'type'=>WS_TYPE_BOOL), |
---|
322 | ), |
---|
323 | 'Retrieves a list of available tags.' |
---|
324 | ); |
---|
325 | |
---|
326 | $service->addMethod( |
---|
327 | 'pwg.tags.getImages', |
---|
328 | 'ws_tags_getImages', |
---|
329 | array_merge(array( |
---|
330 | 'tag_id' => array('default'=>null, |
---|
331 | 'flags'=>WS_PARAM_FORCE_ARRAY, |
---|
332 | 'type'=>WS_TYPE_ID), |
---|
333 | 'tag_url_name' => array('default'=>null, |
---|
334 | 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
335 | 'tag_name' => array('default'=>null, |
---|
336 | 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
337 | 'tag_mode_and' => array('default'=>false, |
---|
338 | 'type'=>WS_TYPE_BOOL), |
---|
339 | 'per_page' => array('default'=>100, |
---|
340 | 'maxValue'=>$conf['ws_max_images_per_page'], |
---|
341 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
342 | 'page' => array('default'=>0, |
---|
343 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
344 | 'order' => array('default'=>null, |
---|
345 | 'info'=>'id, file, name, hit, rating_score, date_creation, date_available, random'), |
---|
346 | ), $f_params), |
---|
347 | 'Returns elements for the corresponding tags. Fill at least tag_id, tag_url_name or tag_name.' |
---|
348 | ); |
---|
349 | |
---|
350 | $service->addMethod( |
---|
351 | 'pwg.images.addChunk', |
---|
352 | 'ws_images_add_chunk', |
---|
353 | array( |
---|
354 | 'data' => array(), |
---|
355 | 'original_sum' => array(), |
---|
356 | 'type' => array('default'=>'file', |
---|
357 | 'info'=>'Must be "file", for backward compatiblity "high" and "thumb" are allowed.'), |
---|
358 | 'position' => array() |
---|
359 | ), |
---|
360 | '<b>Admin & POST only.</b> Add a chunk of a file.' |
---|
361 | ); |
---|
362 | |
---|
363 | $service->addMethod( |
---|
364 | 'pwg.images.addFile', |
---|
365 | 'ws_images_addFile', |
---|
366 | array( |
---|
367 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
368 | 'type' => array('default'=>'file', |
---|
369 | 'info'=>'Must be "file", for backward compatiblity "high" and "thumb" are allowed.'), |
---|
370 | 'sum' => array(), |
---|
371 | ), |
---|
372 | '<b>Admin only.</b> Add or update a file for an existing photo. |
---|
373 | <br>pwg.images.addChunk must have been called before (maybe several times).' |
---|
374 | ); |
---|
375 | |
---|
376 | |
---|
377 | $service->addMethod( |
---|
378 | 'pwg.images.add', |
---|
379 | 'ws_images_add', |
---|
380 | array( |
---|
381 | 'thumbnail_sum' => array('default'=>null), |
---|
382 | 'high_sum' => array('default'=>null), |
---|
383 | 'original_sum' => array(), |
---|
384 | 'original_filename' => array('default'=>null, |
---|
385 | 'Provide it if "check_uniqueness" is true and $conf["uniqueness_mode"] is "filename".'), |
---|
386 | 'name' => array('default'=>null), |
---|
387 | 'author' => array('default'=>null), |
---|
388 | 'date_creation' => array('default'=>null), |
---|
389 | 'comment' => array('default'=>null), |
---|
390 | 'categories' => array('default'=>null, |
---|
391 | 'info'=>'String list "category_id[,rank];category_id[,rank]".<br>The rank is optional and is equivalent to "auto" if not given.'), |
---|
392 | 'tag_ids' => array('default'=>null, |
---|
393 | 'info'=>'Comma separated ids'), |
---|
394 | 'level' => array('default'=>0, |
---|
395 | 'maxValue'=>max($conf['available_permission_levels']), |
---|
396 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
397 | 'check_uniqueness' => array('default'=>true, |
---|
398 | 'type'=>WS_TYPE_BOOL), |
---|
399 | 'image_id' => array('default'=>null, |
---|
400 | 'type'=>WS_TYPE_ID), |
---|
401 | ), |
---|
402 | '<b>Admin only.</b> Add an image. |
---|
403 | <br>pwg.images.addChunk must have been called before (maybe several times). |
---|
404 | <br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.' |
---|
405 | ); |
---|
406 | |
---|
407 | $service->addMethod( |
---|
408 | 'pwg.images.addSimple', |
---|
409 | 'ws_images_addSimple', |
---|
410 | array( |
---|
411 | 'category' => array('default'=>null, |
---|
412 | 'flags'=>WS_PARAM_FORCE_ARRAY, |
---|
413 | 'type'=>WS_TYPE_ID), |
---|
414 | 'name' => array('default'=>null), |
---|
415 | 'author' => array('default'=>null), |
---|
416 | 'comment' => array('default'=>null), |
---|
417 | 'level' => array('default'=>0, |
---|
418 | 'maxValue'=>max($conf['available_permission_levels']), |
---|
419 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
420 | 'tags' => array('default'=>null, |
---|
421 | 'flags'=>WS_PARAM_ACCEPT_ARRAY), |
---|
422 | 'image_id' => array('default'=>null, |
---|
423 | 'type'=>WS_TYPE_ID), |
---|
424 | ), |
---|
425 | '<b>Admin & POST only.</b> Add an image. |
---|
426 | <br>Use the <b>$_FILES[image]</b> field for uploading file. |
---|
427 | <br>Set the form encoding to "form-data". |
---|
428 | <br>You can update an existing photo if you define an existing image_id.' |
---|
429 | ); |
---|
430 | |
---|
431 | $service->addMethod( |
---|
432 | 'pwg.images.delete', |
---|
433 | 'ws_images_delete', |
---|
434 | array( |
---|
435 | 'image_id' => array('flags'=>WS_PARAM_ACCEPT_ARRAY), |
---|
436 | 'pwg_token' => array(), |
---|
437 | ), |
---|
438 | '<b>Admin & POST only.</b> Deletes image(s).' |
---|
439 | ); |
---|
440 | |
---|
441 | $service->addMethod( |
---|
442 | 'pwg.categories.getAdminList', |
---|
443 | 'ws_categories_getAdminList', |
---|
444 | null, |
---|
445 | '<b>Admin only.</b>' |
---|
446 | ); |
---|
447 | |
---|
448 | $service->addMethod( |
---|
449 | 'pwg.categories.add', |
---|
450 | 'ws_categories_add', |
---|
451 | array( |
---|
452 | 'name' => array(), |
---|
453 | 'parent' => array('default'=>null, |
---|
454 | 'type'=>WS_TYPE_ID), |
---|
455 | 'comment' => array('default'=>null), |
---|
456 | 'visible' => array('default'=>true, |
---|
457 | 'type'=>WS_TYPE_BOOL), |
---|
458 | 'status' => array('default'=>null, |
---|
459 | 'info'=>'public, private'), |
---|
460 | 'commentable' => array('default'=>true, |
---|
461 | 'type'=>WS_TYPE_BOOL), |
---|
462 | ), |
---|
463 | '<b>Admin only.</b> Adds an album.' |
---|
464 | ); |
---|
465 | |
---|
466 | $service->addMethod( |
---|
467 | 'pwg.categories.delete', |
---|
468 | 'ws_categories_delete', |
---|
469 | array( |
---|
470 | 'category_id'=> array('flags'=>WS_PARAM_ACCEPT_ARRAY), |
---|
471 | 'photo_deletion_mode' => array('default'=>'delete_orphans'), |
---|
472 | 'pwg_token' => array(), |
---|
473 | ), |
---|
474 | '<b>Admin & POST only.</b> Deletes album(s). |
---|
475 | <br><b>photo_deletion_mode</b> can be "no_delete" (may create orphan photos), "delete_orphans" |
---|
476 | (default mode, only deletes photos linked to no other album) or "force_delete" (delete all photos, even those linked to other albums)' |
---|
477 | ); |
---|
478 | |
---|
479 | $service->addMethod( |
---|
480 | 'pwg.categories.move', |
---|
481 | 'ws_categories_move', |
---|
482 | array( |
---|
483 | 'category_id' => array('flags'=>WS_PARAM_ACCEPT_ARRAY), |
---|
484 | 'parent' => array('type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
485 | 'pwg_token' => array(), |
---|
486 | ), |
---|
487 | '<b>Admin & POST only.</b> Move album(s). |
---|
488 | <br>Set parent as 0 to move to gallery root. Only virtual categories can be moved.' |
---|
489 | ); |
---|
490 | |
---|
491 | $service->addMethod( |
---|
492 | 'pwg.categories.setRepresentative', |
---|
493 | 'ws_categories_setRepresentative', |
---|
494 | array( |
---|
495 | 'category_id' => array('type'=>WS_TYPE_ID), |
---|
496 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
497 | ), |
---|
498 | '<b>Admin & POST only.</b> Sets the representative photo for an album. The photo doesn\'t have to belong to the album.' |
---|
499 | ); |
---|
500 | |
---|
501 | $service->addMethod( |
---|
502 | 'pwg.tags.getAdminList', |
---|
503 | 'ws_tags_getAdminList', |
---|
504 | null, |
---|
505 | '<b>Admin only.</b> ' |
---|
506 | ); |
---|
507 | |
---|
508 | $service->addMethod( // TODO: create multiple tags |
---|
509 | 'pwg.tags.add', |
---|
510 | 'ws_tags_add', |
---|
511 | array('name'), |
---|
512 | '<b>Admin only.</b> Adds a new tag.' |
---|
513 | ); |
---|
514 | |
---|
515 | $service->addMethod( |
---|
516 | 'pwg.images.exist', |
---|
517 | 'ws_images_exist', |
---|
518 | array( |
---|
519 | 'md5sum_list' => array('default'=>null), |
---|
520 | 'filename_list' => array('default'=>null), |
---|
521 | ), |
---|
522 | '<b>Admin only.</b> Checks existence of images. |
---|
523 | <br>Give <b>md5sum_list</b> if $conf[uniqueness_mode]==md5sum. Give <b>filename_list</b> if $conf[uniqueness_mode]==filename.' |
---|
524 | ); |
---|
525 | |
---|
526 | $service->addMethod( |
---|
527 | 'pwg.images.checkFiles', |
---|
528 | 'ws_images_checkFiles', |
---|
529 | array( |
---|
530 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
531 | 'file_sum' => array('default'=>null), |
---|
532 | 'thumbnail_sum' => array('default'=>null), |
---|
533 | 'high_sum' => array('default'=>null), |
---|
534 | ), |
---|
535 | '<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". |
---|
536 | <br>Don\'t use "thumbnail_sum" and "high_sum", these parameters are here for backward compatibility.' |
---|
537 | ); |
---|
538 | |
---|
539 | $service->addMethod( |
---|
540 | 'pwg.images.checkUpload', |
---|
541 | 'ws_images_checkUpload', |
---|
542 | null, |
---|
543 | '<b>Admin only.</b> Checks if Piwigo is ready for upload.' |
---|
544 | ); |
---|
545 | |
---|
546 | $service->addMethod( |
---|
547 | 'pwg.images.setInfo', |
---|
548 | 'ws_images_setInfo', |
---|
549 | array( |
---|
550 | 'image_id' => array('type'=>WS_TYPE_ID), |
---|
551 | 'file' => array('default'=>null), |
---|
552 | 'name' => array('default'=>null), |
---|
553 | 'author' => array('default'=>null), |
---|
554 | 'date_creation' => array('default'=>null), |
---|
555 | 'comment' => array('default'=>null), |
---|
556 | 'categories' => array('default'=>null, |
---|
557 | 'info'=>'String list "category_id[,rank];category_id[,rank]".<br>The rank is optional and is equivalent to "auto" if not given.'), |
---|
558 | 'tag_ids' => array('default'=>null, |
---|
559 | 'info'=>'Comma separated ids'), |
---|
560 | 'level' => array('default'=>null, |
---|
561 | 'maxValue'=>max($conf['available_permission_levels']), |
---|
562 | 'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE), |
---|
563 | 'single_value_mode' => array('default'=>'fill_if_empty'), |
---|
564 | 'multiple_value_mode' => array('default'=>'append'), |
---|
565 | ), |
---|
566 | '<b>Admin & POST only.</b> Changes properties of an image. |
---|
567 | <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" |
---|
568 | (overwrite any existing value) and applies to single values properties like name/author/date_creation/comment. |
---|
569 | <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.' |
---|
570 | ); |
---|
571 | |
---|
572 | $service->addMethod( |
---|
573 | 'pwg.categories.setInfo', |
---|
574 | 'ws_categories_setInfo', |
---|
575 | array( |
---|
576 | 'category_id' => array('type'=>WS_TYPE_ID), |
---|
577 | 'name' => array('default'=>null), |
---|
578 | 'comment' => array('default'=>null), |
---|
579 | ), |
---|
580 | '<b>Admin & POST only.</b> Changes properties of an album.' |
---|
581 | ); |
---|
582 | |
---|
583 | $service->addMethod( |
---|
584 | 'pwg.plugins.getList', |
---|
585 | 'ws_plugins_getList', |
---|
586 | null, |
---|
587 | '<b>Admin only.</b> Gets the list of plugins with id, name, version, state and description.' |
---|
588 | ); |
---|
589 | |
---|
590 | $service->addMethod( |
---|
591 | 'pwg.plugins.performAction', |
---|
592 | 'ws_plugins_performAction', |
---|
593 | array( |
---|
594 | 'action' => array('info'=>'install, activate, deactivate, uninstall, delete'), |
---|
595 | 'plugin' => array(), |
---|
596 | 'pwg_token' => array(), |
---|
597 | ), |
---|
598 | '<b>Admin only.</b>' |
---|
599 | ); |
---|
600 | |
---|
601 | $service->addMethod( |
---|
602 | 'pwg.themes.performAction', |
---|
603 | 'ws_themes_performAction', |
---|
604 | array( |
---|
605 | 'action' => array('info'=>'activate, deactivate, delete, set_default'), |
---|
606 | 'theme' => array(), |
---|
607 | 'pwg_token' => array(), |
---|
608 | ), |
---|
609 | '<b>Admin only.</b>' |
---|
610 | ); |
---|
611 | |
---|
612 | $service->addMethod( |
---|
613 | 'pwg.extensions.update', |
---|
614 | 'ws_extensions_update', |
---|
615 | array( |
---|
616 | 'type' => array('info'=>'plugins, languages, themes'), |
---|
617 | 'id' => array(), |
---|
618 | 'revision' => array(), |
---|
619 | 'pwg_token' => array(), |
---|
620 | ), |
---|
621 | '<b>Webmaster only.</b>' |
---|
622 | ); |
---|
623 | |
---|
624 | $service->addMethod( |
---|
625 | 'pwg.extensions.ignoreUpdate', |
---|
626 | 'ws_extensions_ignoreupdate', |
---|
627 | array( |
---|
628 | 'type' => array('default'=>null, |
---|
629 | 'info'=>'plugins, languages, themes'), |
---|
630 | 'id' => array('default'=>null), |
---|
631 | 'reset' => array('default'=>false, |
---|
632 | 'type'=>WS_TYPE_BOOL, |
---|
633 | 'info'=>'If true, all ignored extensions will be reinitilized.'), |
---|
634 | 'pwg_token' => array(), |
---|
635 | ), |
---|
636 | '<b>Webmaster only.</b> Ignores an extension if it needs update.' |
---|
637 | ); |
---|
638 | |
---|
639 | $service->addMethod( |
---|
640 | 'pwg.extensions.checkUpdates', |
---|
641 | 'ws_extensions_checkupdates', |
---|
642 | null, |
---|
643 | '<b>Admin only.</b> Checks if piwigo or extensions are up to date.' |
---|
644 | ); |
---|
645 | } |
---|
646 | |
---|
647 | ?> |
---|