Changeset 11745 for branches/2.2/include
- Timestamp:
- Jul 14, 2011, 11:43:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/include/ws_functions.inc.php
r11371 r11745 2465 2465 } 2466 2466 2467 function ws_categories_setRepresentative($params, &$service) 2468 { 2469 global $conf; 2470 2471 if (!is_admin()) 2472 { 2473 return new PwgError(401, 'Access denied'); 2474 } 2475 2476 if (!$service->isPost()) 2477 { 2478 return new PwgError(405, "This method requires HTTP POST"); 2479 } 2480 2481 // category_id 2482 // image_id 2483 2484 $params['category_id'] = (int)$params['category_id']; 2485 if ($params['category_id'] <= 0) 2486 { 2487 return new PwgError(WS_ERR_INVALID_PARAM, "Invalid category_id"); 2488 } 2489 2490 // does the category really exist? 2491 $query=' 2492 SELECT 2493 * 2494 FROM '.CATEGORIES_TABLE.' 2495 WHERE id = '.$params['category_id'].' 2496 ;'; 2497 $row = pwg_db_fetch_assoc(pwg_query($query)); 2498 if ($row == null) 2499 { 2500 return new PwgError(404, "category_id not found"); 2501 } 2502 2503 $params['image_id'] = (int)$params['image_id']; 2504 if ($params['image_id'] <= 0) 2505 { 2506 return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id"); 2507 } 2508 2509 // does the image really exist? 2510 $query=' 2511 SELECT 2512 * 2513 FROM '.IMAGES_TABLE.' 2514 WHERE id = '.$params['image_id'].' 2515 ;'; 2516 2517 $row = pwg_db_fetch_assoc(pwg_query($query)); 2518 if ($row == null) 2519 { 2520 return new PwgError(404, "image_id not found"); 2521 } 2522 2523 // apply change 2524 $query = ' 2525 UPDATE '.CATEGORIES_TABLE.' 2526 SET representative_picture_id = '.$params['image_id'].' 2527 WHERE id = '.$params['category_id'].' 2528 ;'; 2529 pwg_query($query); 2530 2531 $query = ' 2532 UPDATE '.USER_CACHE_CATEGORIES_TABLE.' 2533 SET user_representative_picture_id = NULL 2534 WHERE cat_id = '.$params['category_id'].' 2535 ;'; 2536 pwg_query($query); 2537 } 2538 2467 2539 function ws_categories_delete($params, &$service) 2468 2540 {
Note: See TracChangeset
for help on using the changeset viewer.