Changeset 2563
- Timestamp:
- Sep 21, 2008, 10:42:17 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r2553 r2563 437 437 } 438 438 439 /** 440 * returns the list of categories as you can see them in administration (web 441 * service method). 442 * 443 * Only admin can run this method and permissions are not taken into 444 * account. 445 */ 446 function ws_categories_getAdminList($params, &$service) 447 { 448 if (!is_admin()) 449 { 450 return new PwgError(401, 'Access denied'); 451 } 452 453 $query = ' 454 SELECT 455 category_id, 456 COUNT(*) AS counter 457 FROM '.IMAGE_CATEGORY_TABLE.' 458 GROUP BY category_id 459 ;'; 460 $nb_images_of = simple_hash_from_query($query, 'category_id', 'counter'); 461 462 $query = ' 463 SELECT 464 id, 465 name, 466 uppercats, 467 global_rank 468 FROM '.CATEGORIES_TABLE.' 469 ;'; 470 $result = pwg_query($query); 471 $cats = array(); 472 473 while ($row = mysql_fetch_assoc($result)) 474 { 475 $id = $row['id']; 476 $row['nb_images'] = isset($nb_images_of[$id]) ? $nb_images_of[$id] : 0; 477 array_push($cats, $row); 478 } 479 480 usort($cats, 'global_rank_compare'); 481 return array( 482 'categories' => new PwgNamedArray( 483 $cats, 484 'category', 485 array( 486 'id', 487 'nb_images', 488 'name', 489 'uppercats', 490 'global_rank', 491 ) 492 ) 493 ); 494 } 439 495 440 496 /** -
trunk/ws.php
r2520 r2563 187 187 'POST method only' 188 188 ); 189 190 $service->addMethod( 191 'pwg.categories.getAdminList', 192 'ws_categories_getAdminList', 193 array(), 194 'administration method only' 195 ); 189 196 } 190 197
Note: See TracChangeset
for help on using the changeset viewer.