aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2011-12-13 14:58:39 +0000
committerplegall <plg@piwigo.org>2011-12-13 14:58:39 +0000
commit9303b10de8b5f4ba87eb004d75033187dae7b386 (patch)
tree976824396a84891ffc92bca7470e6232db497c93
parentdf9bc84102b7bb5ee57ab07ccac816644057020f (diff)
feature 2532 added: pwg.images.add returns image_id (+url)
git-svn-id: http://piwigo.org/svn/branches/2.3@12727 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--include/ws_functions.inc.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index dd3c79086..24655689a 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -1785,10 +1785,27 @@ SELECT
update_metadata(array($image_id=>$file_path));
}
+ $url_params = array('image_id' => $image_id);
+
// let's add links between the image and the categories
if (isset($params['categories']))
{
ws_add_image_category_relations($image_id, $params['categories']);
+
+ if (preg_match('/^\d+/', $params['categories'], $matches)) {
+ $category_id = $matches[0];
+
+ $query = '
+SELECT id, name, permalink
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id = '.$category_id.'
+;';
+ $result = pwg_query($query);
+ $category = pwg_db_fetch_assoc($result);
+
+ $url_params['section'] = 'categories';
+ $url_params['category'] = $category;
+ }
}
// and now, let's create tag associations
@@ -1801,6 +1818,11 @@ SELECT
}
invalidate_user_cache();
+
+ return array(
+ 'image_id' => $image_id,
+ 'url' => make_picture_url($url_params),
+ );
}
function ws_images_addSimple($params, &$service)