aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-07-15 01:29:23 +0000
committerrvelices <rv-github@modusoptimus.com>2008-07-15 01:29:23 +0000
commit9c96b905ff3327ad5264b794048b6c71bbc5e4ee (patch)
treea0565907ca8d5546ffcd963c952e331e37109c9a /include/ws_functions.inc.php
parentdf29ffbde72e88635f454d5d6d84c5a7209460f3 (diff)
- image rating on picture page done through ajax (tested safari/ie 6&7/ff)
git-svn-id: http://piwigo.org/svn/trunk@2435 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/ws_functions.inc.php')
-rw-r--r--include/ws_functions.inc.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index f115d7865..f8d242e2c 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -775,6 +775,41 @@ SELECT id, date, author, content
return new PwgNamedStruct('image',$ret, null, array('name','comment') );
}
+
+/**
+ * rates the image_id in the parameter
+ */
+function ws_images_Rate($params, &$service)
+{
+ $image_id = (int)$params['image_id'];
+ $query = '
+SELECT DISTINCT id FROM '.IMAGES_TABLE.'
+ INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
+ WHERE id='.$image_id
+ .get_sql_condition_FandF(
+ array(
+ 'forbidden_categories' => 'category_id',
+ 'forbidden_images' => 'id',
+ ),
+ ' AND'
+ ).'
+ LIMIT 1';
+ if ( mysql_num_rows( pwg_query($query) )==0 )
+ {
+ return new PwgError(404, "Invalid image_id or access denied" );
+ }
+ $rate = (int)$params['rate'];
+ include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
+ $res = rate_picture( $image_id, $rate );
+ if ($res==false)
+ {
+ global $conf;
+ return new PwgError( 403, "Forbidden or rate not in ". implode(',',$conf['rate_items']));
+ }
+ return $res;
+}
+
+
/**
* returns a list of elements corresponding to a query search
*/