aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-07-12 00:30:27 +0000
committerrvelices <rv-github@modusoptimus.com>2008-07-12 00:30:27 +0000
commite2ee204c128717069c84437e0aa75bf14b6b352a (patch)
tree72f8059850e19b21168f217aa9a3b09096fdba87 /include/ws_functions.inc.php
parent22ce08c6fbc9f52152ac300156d72256d76a1d64 (diff)
- add to caddie on picture page done through ajax
git-svn-id: http://piwigo.org/svn/trunk@2429 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 72540f2da..f115d7865 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -280,6 +280,34 @@ function ws_getVersion($params, &$service)
return new PwgError(403, 'Forbidden');
}
+function ws_caddie_add($params, &$service)
+{
+ if (!is_admin())
+ {
+ return new PwgError(401, 'Access denied');
+ }
+ if ( empty($params['image_id']) )
+ {
+ return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
+ }
+ global $user;
+ $query = '
+SELECT id
+ FROM '.IMAGES_TABLE.' LEFT JOIN '.CADDIE_TABLE.' ON id=element_id AND user_id='.$user['id'].'
+ WHERE id IN ('.implode(',',$params['image_id']).')
+ AND element_id IS NULL';
+ $datas = array();
+ foreach ( array_from_query($query, 'id') as $id )
+ {
+ array_push($datas, array('element_id'=>$id, 'user_id'=>$user['id']) );
+ }
+ if (count($datas))
+ {
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+ mass_inserts(CADDIE_TABLE, array('element_id','user_id'), $datas);
+ }
+ return count($datas);
+}
/**
* returns images per category (web service method)