Changeset 2548


Ignore:
Timestamp:
Sep 17, 2008, 11:42:50 PM (16 years ago)
Author:
plg
Message:

improvement: webservice methode pwg.categories.getList returns the
images_max_rank for each category, based on #image_category.rank content. So
that a remote client can correctly add photos with webservice method
pwg.images.add.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r2520 r2548  
    365365  global $user,$conf;
    366366
     367  $query = '
     368SELECT
     369    category_id,
     370    MAX(rank) AS max_rank
     371  FROM '.IMAGE_CATEGORY_TABLE.'
     372  WHERE rank IS NOT NULL
     373  GROUP BY category_id
     374;';
     375  $max_image_rank_of = simple_hash_from_query(
     376    $query,
     377    'category_id',
     378    'max_rank'
     379    );
     380
    367381  $where = array();
    368382
     
    416430      $row[$key] = (int)$row[$key];
    417431    }
     432
     433    if (isset($max_image_rank_of[ $row['id'] ]))
     434    {
     435      $row['images_max_rank'] = $max_image_rank_of[ $row['id'] ];
     436    }
     437   
    418438    array_push($cats, $row);
    419439  }
    420440  usort($cats, 'global_rank_compare');
    421441  return array(
    422       'categories' =>
    423           new PwgNamedArray($cats,'category',
    424             array('id','url','nb_images','total_nb_images','nb_categories','date_last','max_date_last')
    425           )
     442    'categories' => new PwgNamedArray(
     443      $cats,
     444      'category',
     445      array(
     446        'id',
     447        'url',
     448        'nb_images',
     449        'total_nb_images',
     450        'nb_categories',
     451        'date_last',
     452        'max_date_last',
     453        'images_max_rank',
     454        )
     455      )
    426456    );
    427457}
Note: See TracChangeset for help on using the changeset viewer.