[1698] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[12922] | 5 | // | Copyright(C) 2008-2012 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 | |
---|
| 24 | define ('PHPWG_ROOT_PATH', './'); |
---|
| 25 | |
---|
| 26 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
[2325] | 27 | check_status(ACCESS_FREE); |
---|
[1698] | 28 | include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php'); |
---|
| 29 | |
---|
[1781] | 30 | if ( !$conf['allow_web_services'] ) |
---|
| 31 | { |
---|
| 32 | page_forbidden('Web services are disabled'); |
---|
| 33 | } |
---|
| 34 | |
---|
[1768] | 35 | /** |
---|
| 36 | * event handler that registers standard methods with the web service |
---|
| 37 | */ |
---|
[1698] | 38 | function ws_addDefaultMethods( $arr ) |
---|
| 39 | { |
---|
| 40 | include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php'); |
---|
[1849] | 41 | global $conf, $user; |
---|
[1698] | 42 | $service = &$arr[0]; |
---|
| 43 | $service->addMethod('pwg.getVersion', 'ws_getVersion', null, |
---|
| 44 | 'retrieves the PWG version'); |
---|
[10017] | 45 | |
---|
| 46 | $service->addMethod('pwg.getInfos', 'ws_getInfos', null, |
---|
| 47 | 'retrieves general informations'); |
---|
[1698] | 48 | |
---|
[2435] | 49 | $service->addMethod('pwg.caddie.add', 'ws_caddie_add', |
---|
[2429] | 50 | array( |
---|
| 51 | 'image_id'=> array( 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 52 | ), |
---|
| 53 | 'adds the elements to the caddie'); |
---|
| 54 | |
---|
[1698] | 55 | $service->addMethod('pwg.categories.getImages', 'ws_categories_getImages', |
---|
| 56 | array( |
---|
| 57 | 'cat_id'=>array('default'=>0, 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
| 58 | 'recursive'=>array('default'=>false), |
---|
[1781] | 59 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
[1698] | 60 | 'page' => array('default'=>0), |
---|
| 61 | 'order' => array('default'=>null), |
---|
| 62 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 63 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 64 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 65 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 66 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 67 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 68 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 69 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 70 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 71 | 'f_max_ratio' => array( 'default'=> null ), |
---|
[12865] | 72 | 'f_max_level' => array( 'default'=> null ), |
---|
[1698] | 73 | ), |
---|
| 74 | 'Returns elements for the corresponding categories. |
---|
[3185] | 75 | <br><b>cat_id</b> can be empty if <b>recursive</b> is true. Can be sent as an array. |
---|
[11893] | 76 | <br><b>order</b> comma separated fields for sorting (file,id, rating_score,...)' |
---|
[1698] | 77 | ); |
---|
| 78 | |
---|
| 79 | $service->addMethod('pwg.categories.getList', 'ws_categories_getList', |
---|
| 80 | array( |
---|
| 81 | 'cat_id' => array('default'=>0), |
---|
| 82 | 'recursive' => array('default'=>false), |
---|
| 83 | 'public' => array('default'=>false), |
---|
[11155] | 84 | 'tree_output' => array('default'=>false), |
---|
[11962] | 85 | 'fullname' => array('default'=>false), |
---|
[1698] | 86 | ), |
---|
[11155] | 87 | 'retrieves a list of categories (tree_output option only compatible with json/php output format' ); |
---|
[1698] | 88 | |
---|
[12865] | 89 | $service->addMethod('pwg.getMissingDerivatives', 'ws_getMissingDerivatives', |
---|
| 90 | array( |
---|
| 91 | 'types' => array( 'default'=>array(), 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
[13544] | 92 | 'ids' => array( 'default'=>array(), 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
[12865] | 93 | 'max_urls' => array( 'default' => 200 ), |
---|
| 94 | 'prev_page' => array( 'default'=> null), |
---|
| 95 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 96 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 97 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 98 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 99 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 100 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 101 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 102 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 103 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 104 | 'f_max_ratio' => array( 'default'=> null ), |
---|
| 105 | 'f_max_level' => array( 'default'=> null ), |
---|
| 106 | ), |
---|
| 107 | 'retrieves a list of derivatives to build' ); |
---|
| 108 | |
---|
[1849] | 109 | $service->addMethod('pwg.images.addComment', 'ws_images_addComment', |
---|
| 110 | array( |
---|
| 111 | 'image_id' => array(), |
---|
[2029] | 112 | 'author' => array( 'default' => is_a_guest()? 'guest':$user['username']), |
---|
[1849] | 113 | 'content' => array(), |
---|
| 114 | 'key' => array(), |
---|
| 115 | ), |
---|
| 116 | 'add a comment to an image' ); |
---|
| 117 | |
---|
[1698] | 118 | $service->addMethod('pwg.images.getInfo', 'ws_images_getInfo', |
---|
[1849] | 119 | array( |
---|
| 120 | 'image_id' => array(), |
---|
| 121 | 'comments_page' => array('default'=>0 ), |
---|
[2435] | 122 | 'comments_per_page' => array( |
---|
| 123 | 'default' => $conf['nb_comment_page'], |
---|
[1849] | 124 | 'maxValue' => 2*$conf['nb_comment_page'], |
---|
| 125 | ), |
---|
| 126 | ), |
---|
[1698] | 127 | 'retrieves information about the given photo' ); |
---|
| 128 | |
---|
[2435] | 129 | $service->addMethod('pwg.images.rate', 'ws_images_rate', |
---|
| 130 | array( |
---|
| 131 | 'image_id' => array(), |
---|
| 132 | 'rate' => array(), |
---|
| 133 | ), |
---|
| 134 | 'rate the image' ); |
---|
| 135 | |
---|
[1837] | 136 | $service->addMethod('pwg.images.search', 'ws_images_search', |
---|
| 137 | array( |
---|
| 138 | 'query'=>array(), |
---|
| 139 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
| 140 | 'page' => array('default'=>0), |
---|
| 141 | 'order' => array('default'=>null), |
---|
| 142 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 143 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 144 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 145 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 146 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 147 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 148 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 149 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 150 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 151 | 'f_max_ratio' => array( 'default'=> null ), |
---|
[12865] | 152 | 'f_max_level' => array( 'default'=> null ), |
---|
[1837] | 153 | ), |
---|
| 154 | 'Returns elements for the corresponding query search.' |
---|
| 155 | ); |
---|
[2516] | 156 | |
---|
[2463] | 157 | $service->addMethod( |
---|
| 158 | 'pwg.images.setPrivacyLevel', |
---|
| 159 | 'ws_images_setPrivacyLevel', |
---|
| 160 | array( |
---|
| 161 | 'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY), |
---|
| 162 | 'level' => array('maxValue'=>$conf['available_permission_levels']), |
---|
[2413] | 163 | ), |
---|
[4513] | 164 | 'sets the privacy levels for the images (POST method only)' |
---|
[2463] | 165 | ); |
---|
[1837] | 166 | |
---|
[11372] | 167 | $service->addMethod( |
---|
| 168 | 'pwg.images.setRank', |
---|
| 169 | 'ws_images_setRank', |
---|
| 170 | array( |
---|
| 171 | 'image_id' => array(), |
---|
| 172 | 'category_id' => array(), |
---|
| 173 | 'rank' => array(), |
---|
| 174 | ), |
---|
| 175 | 'sets the rank of a photo for a given album (POST method only, for admins)' |
---|
| 176 | ); |
---|
[12624] | 177 | |
---|
| 178 | |
---|
| 179 | $service->addMethod('pwg.rates.delete', 'ws_rates_delete', |
---|
| 180 | array( |
---|
| 181 | 'user_id' => array(), |
---|
| 182 | 'anonymous_id' => array( 'default'=>'' ), |
---|
| 183 | ), |
---|
| 184 | 'deletes all rates for a user (POST method only, admins only)' |
---|
| 185 | ); |
---|
| 186 | |
---|
[1698] | 187 | $service->addMethod('pwg.session.getStatus', 'ws_session_getStatus', null, '' ); |
---|
| 188 | $service->addMethod('pwg.session.login', 'ws_session_login', |
---|
| 189 | array('username', 'password'), |
---|
| 190 | 'POST method only' ); |
---|
| 191 | $service->addMethod('pwg.session.logout', 'ws_session_logout', null, ''); |
---|
| 192 | |
---|
| 193 | $service->addMethod('pwg.tags.getList', 'ws_tags_getList', |
---|
| 194 | array('sort_by_counter' => array('default' =>false) ), |
---|
| 195 | 'retrieves a list of available tags'); |
---|
| 196 | $service->addMethod('pwg.tags.getImages', 'ws_tags_getImages', |
---|
| 197 | array( |
---|
| 198 | 'tag_id'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 199 | 'tag_url_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 200 | 'tag_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 201 | 'tag_mode_and'=>array('default'=>false), |
---|
[1781] | 202 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
[1698] | 203 | 'page' => array('default'=>0), |
---|
| 204 | 'order' => array('default'=>null), |
---|
| 205 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 206 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 207 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 208 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 209 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 210 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 211 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 212 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 213 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 214 | 'f_max_ratio' => array( 'default'=> null ), |
---|
[12865] | 215 | 'f_max_level' => array( 'default'=> null ), |
---|
[1698] | 216 | ), |
---|
| 217 | 'Returns elements for the corresponding tags. Note that tag_id, tag_url_name, tag_name an be arrays. Fill at least one of them. ' |
---|
| 218 | ); |
---|
[2463] | 219 | |
---|
| 220 | $service->addMethod( |
---|
[3193] | 221 | 'pwg.images.addChunk', |
---|
| 222 | 'ws_images_add_chunk', |
---|
| 223 | array( |
---|
| 224 | 'data' => array(), |
---|
| 225 | 'original_sum' => array(), |
---|
| 226 | 'type' => array(), |
---|
| 227 | 'position' => array(), |
---|
| 228 | ), |
---|
| 229 | 'POST method only. For admin only.' |
---|
| 230 | ); |
---|
| 231 | |
---|
| 232 | $service->addMethod( |
---|
[4348] | 233 | 'pwg.images.addFile', |
---|
| 234 | 'ws_images_addFile', |
---|
| 235 | array( |
---|
| 236 | 'image_id' => array(), |
---|
| 237 | 'type' => array(), |
---|
| 238 | 'sum' => array(), |
---|
| 239 | ), |
---|
| 240 | 'Add or update a file for an existing photo. pwg.images.addChunk must have been called before (maybe several times)' |
---|
| 241 | ); |
---|
| 242 | |
---|
| 243 | |
---|
| 244 | $service->addMethod( |
---|
[2463] | 245 | 'pwg.images.add', |
---|
| 246 | 'ws_images_add', |
---|
| 247 | array( |
---|
[2569] | 248 | 'file_sum' => array(), |
---|
[12724] | 249 | 'thumbnail_sum' => array('default' => null), |
---|
[2670] | 250 | 'high_sum' => array('default' => null), |
---|
[3065] | 251 | 'original_sum' => array(), |
---|
[4911] | 252 | 'original_filename' => array('default' => null), |
---|
[2569] | 253 | 'name' => array('default' => null), |
---|
| 254 | 'author' => array('default' => null), |
---|
| 255 | 'date_creation' => array('default' => null), |
---|
| 256 | 'comment' => array('default' => null), |
---|
| 257 | 'categories' => array('default' => null), |
---|
| 258 | 'tag_ids' => array('default' => null), |
---|
| 259 | 'level' => array( |
---|
| 260 | 'default' => 0, |
---|
| 261 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 262 | ), |
---|
[12726] | 263 | 'check_uniqueness' => array('default' => true), |
---|
[13090] | 264 | 'image_id' => array('default' => null), |
---|
[2463] | 265 | ), |
---|
[2569] | 266 | 'POST method only. |
---|
[3185] | 267 | <br><b>categories</b> is a string list "category_id[,rank];category_id[,rank]" The rank is optional and is equivalent to "auto" if not given.' |
---|
[2463] | 268 | ); |
---|
[2563] | 269 | |
---|
| 270 | $service->addMethod( |
---|
[8249] | 271 | 'pwg.images.addSimple', |
---|
| 272 | 'ws_images_addSimple', |
---|
| 273 | array( |
---|
| 274 | 'category' => array('default' => null), |
---|
| 275 | 'name' => array('default' => null), |
---|
| 276 | 'author' => array('default' => null), |
---|
| 277 | 'comment' => array('default' => null), |
---|
| 278 | 'level' => array( |
---|
| 279 | 'default' => 0, |
---|
| 280 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 281 | ), |
---|
| 282 | 'tags' => array('default' => null), |
---|
[9191] | 283 | 'image_id' => array('default' => null), |
---|
[8249] | 284 | ), |
---|
[9191] | 285 | 'POST method only.<br>Use the <b>image</b> field for uploading file.<br>Set the form encoding to "form-data"<br><b>category</b> is the numeric identifier of the destination category.<br>You can update an existing photo if you define an existing image_id.' |
---|
[8249] | 286 | ); |
---|
[8266] | 287 | |
---|
[8249] | 288 | $service->addMethod( |
---|
[8266] | 289 | 'pwg.images.delete', |
---|
| 290 | 'ws_images_delete', |
---|
| 291 | array( |
---|
| 292 | 'image_id'=>array('default'=>0), |
---|
[10502] | 293 | 'pwg_token' => array(), |
---|
[8266] | 294 | ), |
---|
| 295 | 'Delete photos. You can give several image_ids, comma separated' |
---|
| 296 | ); |
---|
| 297 | |
---|
| 298 | $service->addMethod( |
---|
[2563] | 299 | 'pwg.categories.getAdminList', |
---|
| 300 | 'ws_categories_getAdminList', |
---|
| 301 | array(), |
---|
| 302 | 'administration method only' |
---|
| 303 | ); |
---|
[2583] | 304 | |
---|
| 305 | $service->addMethod( |
---|
| 306 | 'pwg.categories.add', |
---|
| 307 | 'ws_categories_add', |
---|
| 308 | array( |
---|
| 309 | 'name' => array(), |
---|
| 310 | 'parent' => array('default' => null), |
---|
[15850] | 311 | 'comment' => array('default' => null), |
---|
[17669] | 312 | 'visible' => array('default' => null), |
---|
| 313 | 'status' => array('default' => null), |
---|
[15850] | 314 | 'commentable' => array('default' => 'true'), |
---|
[2583] | 315 | ), |
---|
| 316 | 'administration method only' |
---|
| 317 | ); |
---|
[2584] | 318 | |
---|
| 319 | $service->addMethod( |
---|
[8266] | 320 | 'pwg.categories.delete', |
---|
| 321 | 'ws_categories_delete', |
---|
| 322 | array( |
---|
| 323 | 'category_id'=>array('default'=>0), |
---|
[10502] | 324 | 'pwg_token' => array(), |
---|
[8266] | 325 | 'photo_deletion_mode' => array('default' => 'delete_orphans'), |
---|
| 326 | ), |
---|
| 327 | 'Delete categories. You can give several category_ids, comma separated. |
---|
| 328 | <br><b>photo_deletion_mode</b> can be "no_delete" (may create orphan photos), "delete_orphans" (default mode, only deletes photos linked to no other album) or "force_delete" (delete all photos, even those linked to other albums)' |
---|
| 329 | ); |
---|
| 330 | |
---|
| 331 | $service->addMethod( |
---|
[8272] | 332 | 'pwg.categories.move', |
---|
| 333 | 'ws_categories_move', |
---|
| 334 | array( |
---|
| 335 | 'category_id'=>array('default'=>0), |
---|
| 336 | 'parent'=>array('default'=>0), |
---|
[10502] | 337 | 'pwg_token' => array(), |
---|
[8272] | 338 | ), |
---|
| 339 | 'Move categories. You can give several category_ids, comma separated. Set parent as 0 to move to gallery root. Only virtual categories can be moved.' |
---|
| 340 | ); |
---|
[11746] | 341 | |
---|
[8272] | 342 | $service->addMethod( |
---|
[11746] | 343 | 'pwg.categories.setRepresentative', |
---|
| 344 | 'ws_categories_setRepresentative', |
---|
| 345 | array( |
---|
| 346 | 'category_id'=>array('default'=>0), |
---|
| 347 | 'image_id'=>array('default'=>0), |
---|
| 348 | ), |
---|
| 349 | 'Set the representative photo for an album. The photo doesn\'t have to belong to the album. POST method only. Administration method only.' |
---|
| 350 | ); |
---|
| 351 | |
---|
| 352 | $service->addMethod( |
---|
[2584] | 353 | 'pwg.tags.getAdminList', |
---|
| 354 | 'ws_tags_getAdminList', |
---|
| 355 | array(), |
---|
| 356 | 'administration method only' |
---|
| 357 | ); |
---|
[2634] | 358 | |
---|
| 359 | $service->addMethod( |
---|
| 360 | 'pwg.tags.add', |
---|
| 361 | 'ws_tags_add', |
---|
| 362 | array( |
---|
| 363 | 'name' => array(), |
---|
| 364 | ), |
---|
| 365 | 'administration method only' |
---|
| 366 | ); |
---|
[2683] | 367 | |
---|
| 368 | $service->addMethod( |
---|
| 369 | 'pwg.images.exist', |
---|
| 370 | 'ws_images_exist', |
---|
| 371 | array( |
---|
[4954] | 372 | 'md5sum_list'=> array('default' => null), |
---|
| 373 | 'filename_list' => array('default' => null), |
---|
[2683] | 374 | ), |
---|
| 375 | 'check existence of a photo list' |
---|
| 376 | ); |
---|
[2919] | 377 | |
---|
| 378 | $service->addMethod( |
---|
[4347] | 379 | 'pwg.images.checkFiles', |
---|
| 380 | 'ws_images_checkFiles', |
---|
| 381 | array( |
---|
| 382 | 'image_id' => array(), |
---|
| 383 | 'thumbnail_sum' => array('default' => null), |
---|
| 384 | 'file_sum' => array('default' => null), |
---|
| 385 | 'high_sum' => array('default' => null), |
---|
| 386 | ), |
---|
| 387 | 'check if you have updated version of your files for a given photo, for each requested file type, the answer can be "missing", "equals" or "differs"' |
---|
| 388 | ); |
---|
| 389 | |
---|
| 390 | $service->addMethod( |
---|
[6049] | 391 | 'pwg.images.checkUpload', |
---|
| 392 | 'ws_images_checkUpload', |
---|
| 393 | null, |
---|
| 394 | 'check if Piwigo is ready for upload' |
---|
| 395 | ); |
---|
| 396 | |
---|
| 397 | $service->addMethod( |
---|
[2919] | 398 | 'pwg.images.setInfo', |
---|
| 399 | 'ws_images_setInfo', |
---|
| 400 | array( |
---|
| 401 | 'image_id' => array(), |
---|
[4513] | 402 | |
---|
[12730] | 403 | 'file' => array('default' => null), |
---|
[2919] | 404 | 'name' => array('default' => null), |
---|
| 405 | 'author' => array('default' => null), |
---|
| 406 | 'date_creation' => array('default' => null), |
---|
| 407 | 'comment' => array('default' => null), |
---|
| 408 | 'categories' => array('default' => null), |
---|
| 409 | 'tag_ids' => array('default' => null), |
---|
| 410 | 'level' => array( |
---|
[11366] | 411 | 'default' => null, |
---|
[2919] | 412 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 413 | ), |
---|
[4460] | 414 | 'single_value_mode' => array('default' => 'fill_if_empty'), |
---|
| 415 | 'multiple_value_mode' => array('default' => 'append'), |
---|
[2919] | 416 | ), |
---|
| 417 | 'POST method only. Admin only |
---|
[4460] | 418 | <br><b>categories</b> is a string list "category_id[,rank];category_id[,rank]" The rank is optional and is equivalent to "auto" if not given. |
---|
| 419 | <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" (overwrite any existing value) and applies to single values properties like name/author/date_creation/comment |
---|
| 420 | <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' |
---|
[2919] | 421 | ); |
---|
[4513] | 422 | |
---|
[3454] | 423 | $service->addMethod( |
---|
| 424 | 'pwg.categories.setInfo', |
---|
| 425 | 'ws_categories_setInfo', |
---|
| 426 | array( |
---|
| 427 | 'category_id' => array(), |
---|
[4513] | 428 | |
---|
[3454] | 429 | 'name' => array('default' => null), |
---|
| 430 | 'comment' => array('default' => null), |
---|
| 431 | ), |
---|
| 432 | 'POST method only.' |
---|
| 433 | ); |
---|
[8273] | 434 | |
---|
| 435 | $service->addMethod( |
---|
| 436 | 'pwg.plugins.getList', |
---|
| 437 | 'ws_plugins_getList', |
---|
| 438 | array(), |
---|
| 439 | 'get the list of plugin with id, name, version, state and description |
---|
| 440 | <br>administration status required' |
---|
| 441 | ); |
---|
| 442 | |
---|
| 443 | $service->addMethod( |
---|
| 444 | 'pwg.plugins.performAction', |
---|
| 445 | 'ws_plugins_performAction', |
---|
| 446 | array( |
---|
[10502] | 447 | 'action' => array(), |
---|
| 448 | 'plugin' => array(), |
---|
| 449 | 'pwg_token' => array(), |
---|
[8273] | 450 | ), |
---|
| 451 | 'install/activate/deactivate/uninstall/delete a plugin |
---|
| 452 | <br>administration status required' |
---|
| 453 | ); |
---|
[8309] | 454 | |
---|
| 455 | $service->addMethod( |
---|
| 456 | 'pwg.themes.performAction', |
---|
| 457 | 'ws_themes_performAction', |
---|
| 458 | array( |
---|
[10502] | 459 | 'action' => array(), |
---|
| 460 | 'theme' => array(), |
---|
| 461 | 'pwg_token' => array(), |
---|
[8309] | 462 | ), |
---|
| 463 | 'activate/deactivate/delete/set_default a theme<br>administration status required' |
---|
| 464 | ); |
---|
[10235] | 465 | |
---|
| 466 | $service->addMethod( |
---|
[10511] | 467 | 'pwg.extensions.update', |
---|
| 468 | 'ws_extensions_update', |
---|
| 469 | array( |
---|
| 470 | 'type' => array(), |
---|
| 471 | 'id' => array(), |
---|
| 472 | 'revision'=> array(), |
---|
| 473 | 'pwg_token' => array(), |
---|
| 474 | ), |
---|
| 475 | 'Update an extension. Webmaster only. |
---|
| 476 | <br>Parameter type must be "plugins", "languages" or "themes".' |
---|
| 477 | ); |
---|
| 478 | |
---|
| 479 | $service->addMethod( |
---|
| 480 | 'pwg.extensions.ignoreUpdate', |
---|
| 481 | 'ws_extensions_ignoreupdate', |
---|
| 482 | array( |
---|
| 483 | 'type' => array('default'=>null), |
---|
| 484 | 'id' => array('default'=>null), |
---|
| 485 | 'reset' => array('default'=>null), |
---|
| 486 | 'pwg_token' => array(), |
---|
| 487 | ), |
---|
| 488 | 'Ignore an extension if it need update. |
---|
| 489 | <br>Parameter type must be "plugins", "languages" or "themes". |
---|
| 490 | <br>If reset parameter is true, all ignored extensions will be reinitilized.' |
---|
| 491 | ); |
---|
[10538] | 492 | |
---|
| 493 | $service->addMethod( |
---|
| 494 | 'pwg.extensions.checkUpdates', |
---|
| 495 | 'ws_extensions_checkupdates', |
---|
| 496 | array(), |
---|
| 497 | 'Check if piwigo or extensions are up to date.' |
---|
| 498 | ); |
---|
[1698] | 499 | } |
---|
| 500 | |
---|
[1768] | 501 | add_event_handler('ws_add_methods', 'ws_addDefaultMethods'); |
---|
[1698] | 502 | |
---|
[1768] | 503 | |
---|
| 504 | add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
| 505 | |
---|
[12695] | 506 | $requestFormat = 'rest'; |
---|
[1698] | 507 | $responseFormat = null; |
---|
| 508 | |
---|
| 509 | if ( isset($_GET['format']) ) |
---|
| 510 | { |
---|
| 511 | $responseFormat = $_GET['format']; |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | if ( !isset($responseFormat) and isset($requestFormat) ) |
---|
| 515 | { |
---|
| 516 | $responseFormat = $requestFormat; |
---|
| 517 | } |
---|
| 518 | |
---|
| 519 | $service = new PwgServer(); |
---|
| 520 | |
---|
| 521 | if (!is_null($requestFormat)) |
---|
| 522 | { |
---|
| 523 | $handler = null; |
---|
| 524 | switch ($requestFormat) |
---|
| 525 | { |
---|
| 526 | case 'rest': |
---|
| 527 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_handler.php'); |
---|
| 528 | $handler = new PwgRestRequestHandler(); |
---|
| 529 | break; |
---|
| 530 | } |
---|
| 531 | $service->setHandler($requestFormat, $handler); |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | if (!is_null($responseFormat)) |
---|
| 535 | { |
---|
| 536 | $encoder = null; |
---|
| 537 | switch ($responseFormat) |
---|
| 538 | { |
---|
| 539 | case 'rest': |
---|
| 540 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_encoder.php'); |
---|
| 541 | $encoder = new PwgRestEncoder(); |
---|
| 542 | break; |
---|
| 543 | case 'php': |
---|
| 544 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/php_encoder.php'); |
---|
| 545 | $encoder = new PwgSerialPhpEncoder(); |
---|
| 546 | break; |
---|
| 547 | case 'json': |
---|
| 548 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php'); |
---|
| 549 | $encoder = new PwgJsonEncoder(); |
---|
| 550 | break; |
---|
| 551 | case 'xmlrpc': |
---|
| 552 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php'); |
---|
| 553 | $encoder = new PwgXmlRpcEncoder(); |
---|
| 554 | break; |
---|
| 555 | } |
---|
| 556 | $service->setEncoder($responseFormat, $encoder); |
---|
| 557 | } |
---|
| 558 | |
---|
[1750] | 559 | set_make_full_url(); |
---|
[1698] | 560 | $service->run(); |
---|
| 561 | |
---|
| 562 | ?> |
---|