Ignore:
Timestamp:
Jul 15, 2008, 3:29:23 AM (16 years ago)
Author:
rvelices
Message:
  • image rating on picture page done through ajax (tested safari/ie 6&7/ff)
File:
1 edited

Legend:

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

    r2429 r2435  
    775775  return new PwgNamedStruct('image',$ret, null, array('name','comment') );
    776776}
     777
     778
     779/**
     780 * rates the image_id in the parameter
     781 */
     782function ws_images_Rate($params, &$service)
     783{
     784  $image_id = (int)$params['image_id'];
     785  $query = '
     786SELECT DISTINCT id FROM '.IMAGES_TABLE.'
     787  INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
     788  WHERE id='.$image_id
     789  .get_sql_condition_FandF(
     790    array(
     791        'forbidden_categories' => 'category_id',
     792        'forbidden_images' => 'id',
     793      ),
     794    '    AND'
     795    ).'
     796    LIMIT 1';
     797  if ( mysql_num_rows( pwg_query($query) )==0 )
     798  {
     799    return new PwgError(404, "Invalid image_id or access denied" );
     800  }
     801  $rate = (int)$params['rate'];
     802  include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
     803  $res = rate_picture( $image_id, $rate );
     804  if ($res==false)
     805  {
     806    global $conf;
     807    return new PwgError( 403, "Forbidden or rate not in ". implode(',',$conf['rate_items']));
     808  }
     809  return $res;
     810}
     811
    777812
    778813/**
Note: See TracChangeset for help on using the changeset viewer.