Changeset 25678 for extensions/UserCollections/include/ws_functions.inc.php
- Timestamp:
- Nov 24, 2013, 6:09:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserCollections/include/ws_functions.inc.php
r24421 r25678 6 6 $service = &$arr[0]; 7 7 global $conf; 8 8 9 9 $service->addMethod( 10 10 'pwg.collections.create', … … 17 17 'Create a new User Collection.' 18 18 ); 19 19 20 20 $service->addMethod( 21 21 'pwg.collections.delete', … … 26 26 'Delete a User Collection.' 27 27 ); 28 28 29 29 $service->addMethod( 30 30 'pwg.collections.getList', … … 42 42 'Returns a list of collections.' 43 43 ); 44 44 45 45 $service->addMethod( 46 46 'pwg.collections.addImages', … … 52 52 'Add images to a collection.' 53 53 ); 54 54 55 55 $service->addMethod( 56 56 'pwg.collections.removeImages', … … 62 62 'Remove images from a collection.' 63 63 ); 64 64 65 65 $service->addMethod( 66 66 'pwg.collections.getImages', … … 74 74 'Returns elements for the corresponding collection.' 75 75 ); 76 76 77 77 $service->addMethod( 78 78 'pwg.collections.getSerialized', … … 88 88 'Returns a serialized version of the collection in CSV.<br>The return type is plain/text whatever you select as response format.' 89 89 ); 90 90 91 91 $service->addMethod( 92 92 'pwg.collections.getInfo', … … 105 105 { 106 106 global $conf, $user; 107 108 // check status 109 if (is_a_guest()) 110 { 111 return new PwgError(403, 'Forbidden'); 112 } 113 107 108 // check status 109 if (is_a_guest()) 110 { 111 return new PwgError(403, 'Forbidden'); 112 } 113 114 114 // check name 115 115 if (empty($params['name'])) … … 117 117 return new PwgError(WS_ERR_MISSING_PARAM, 'Empty collection name'); 118 118 } 119 119 120 120 // check user id 121 121 if (!empty($params['user_id'])) … … 135 135 $params['user_id'] = $user['id']; 136 136 } 137 137 138 138 $collection = new UserCollection('new', $params['name'], $params['comment'], $params['user_id']); 139 139 140 140 return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER); 141 141 } … … 147 147 { 148 148 global $user; 149 150 // check status 151 if (is_a_guest()) 152 { 153 return new PwgError(403, 'Forbidden'); 154 } 155 156 try { 157 $collection = new UserCollection($params['col_id']); 158 $collection->checkUser(); 159 149 150 // check status 151 if (is_a_guest()) 152 { 153 return new PwgError(403, 'Forbidden'); 154 } 155 156 try { 157 $collection = new UserCollection($params['col_id']); 158 $collection->checkUser(); 159 160 160 $collection->delete(); 161 161 } … … 172 172 { 173 173 global $user, $conf; 174 175 // check status 176 if (is_a_guest()) 177 { 178 return new PwgError(403, 'Forbidden'); 179 } 180 174 175 // check status 176 if (is_a_guest()) 177 { 178 return new PwgError(403, 'Forbidden'); 179 } 180 181 181 // check user_id 182 182 if (!empty($params['user_id'])) … … 196 196 $params['user_id'] = $user['id']; 197 197 } 198 198 199 199 // search 200 200 $where_clauses = array('1=1'); … … 207 207 $where_clauses[] = 'name LIKE("%'.pwg_db_real_escape_string($params['name']).'%")'; 208 208 } 209 209 210 210 $order_by = !empty($params['order']) ? $params['order'] : 'username ASC, name ASC'; 211 211 212 212 $query = ' 213 SELECT 213 SELECT 214 214 c.*, 215 215 u.'.$conf['user_fields']['username'].' AS username … … 223 223 ;'; 224 224 $sets = hash_from_query($query, 'id'); 225 225 226 226 $data = array(); 227 227 foreach ($sets as $row) … … 238 238 ); 239 239 } 240 240 241 241 return array( 242 242 'paging' => new PwgNamedStruct(array( … … 250 250 ) 251 251 ); 252 252 253 253 return $ret; 254 254 } … … 260 260 { 261 261 global $conf, $user; 262 263 // check status 264 if (is_a_guest()) 265 { 266 return new PwgError(403, 'Forbidden'); 267 } 268 269 try { 270 $collection = new UserCollection($params['col_id']); 271 $collection->checkUser(); 272 262 263 // check status 264 if (is_a_guest()) 265 { 266 return new PwgError(403, 'Forbidden'); 267 } 268 269 try { 270 $collection = new UserCollection($params['col_id']); 271 $collection->checkUser(); 272 273 273 $collection->addImages($params['image_ids']); 274 274 275 275 return array('nb_images' => $collection->getParam('nb_images')); 276 276 } … … 287 287 { 288 288 global $conf, $user; 289 290 // check status 291 if (is_a_guest()) 292 { 293 return new PwgError(403, 'Forbidden'); 294 } 295 296 try { 297 $collection = new UserCollection($params['col_id']); 298 $collection->checkUser(); 299 289 290 // check status 291 if (is_a_guest()) 292 { 293 return new PwgError(403, 'Forbidden'); 294 } 295 296 try { 297 $collection = new UserCollection($params['col_id']); 298 $collection->checkUser(); 299 300 300 $collection->removeImages($params['image_ids']); 301 301 302 302 return array('nb_images' => $collection->getParam('nb_images')); 303 303 } … … 314 314 { 315 315 global $conf, $user; 316 317 // check status 318 if (is_a_guest()) 319 { 320 return new PwgError(403, 'Forbidden'); 321 } 322 323 try { 324 $collection = new UserCollection($params['col_id']); 325 $collection->checkUser(); 326 316 317 // check status 318 if (is_a_guest()) 319 { 320 return new PwgError(403, 'Forbidden'); 321 } 322 323 try { 324 $collection = new UserCollection($params['col_id']); 325 $collection->checkUser(); 326 327 327 $image_ids = $collection->getImages(); 328 328 $images = array(); 329 329 330 330 if (!empty($image_ids)) 331 331 { … … 343 343 SELECT i.* 344 344 FROM '.IMAGES_TABLE.' i 345 WHERE 345 WHERE 346 346 '. implode("\n AND ", $where_clauses).' 347 347 GROUP BY i.id … … 366 366 } 367 367 $image = array_merge($image, ws_std_get_urls($row)); 368 368 369 369 array_push($images, $image); 370 370 } 371 371 } 372 372 373 373 return array( 374 374 'paging' => new PwgNamedStruct(array( … … 396 396 { 397 397 global $conf, $user; 398 399 // check status 400 if (is_a_guest()) 401 { 402 return new PwgError(403, 'Forbidden'); 403 } 404 405 try { 406 $collection = new UserCollection($params['col_id']); 407 $collection->checkUser(); 408 398 399 // check status 400 if (is_a_guest()) 401 { 402 return new PwgError(403, 'Forbidden'); 403 } 404 405 try { 406 $collection = new UserCollection($params['col_id']); 407 $collection->checkUser(); 408 409 409 // change encoder to plain text 410 410 include_once(USER_COLLEC_PATH.'include/plain_encoder.php'); 411 411 $encoder = new PwgPlainEncoder(); 412 412 $service->setEncoder('plain', $encoder); 413 413 414 414 return $collection->serialize($params['content']); 415 415 } … … 426 426 { 427 427 global $conf, $user; 428 429 // check status 430 if (is_a_guest()) 431 { 432 return new PwgError(403, 'Forbidden'); 433 } 434 435 try { 436 $collection = new UserCollection($params['col_id']); 437 $collection->checkUser(); 438 428 429 // check status 430 if (is_a_guest()) 431 { 432 return new PwgError(403, 'Forbidden'); 433 } 434 435 try { 436 $collection = new UserCollection($params['col_id']); 437 $collection->checkUser(); 438 439 439 return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER); 440 440 } … … 444 444 } 445 445 } 446 447 ?>
Note: See TracChangeset
for help on using the changeset viewer.