aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/addtag.php34
1 files changed, 26 insertions, 8 deletions
diff --git a/actions/addtag.php b/actions/addtag.php
index 309058e1c..562d53882 100644
--- a/actions/addtag.php
+++ b/actions/addtag.php
@@ -8,33 +8,51 @@
action_gatekeeper();
$coordinates_str = get_input('coordinates');
- error_log($coordinates_str);
$user_id = get_input('user_id');
$image_guid = get_input('image_guid');
$word = get_input('word');
- error_log($word);
- error_log($user_id);
-
if ($image_guid == 0) {
- register_error("error");
+ register_error(elgg_echo("tidypics:phototagging:error"));
forward($_SERVER['HTTP_REFERER']);
}
$image = get_entity($image_guid);
if (!$image)
{
- register_error(elgg_echo("image:phototagging:notexists"));
+ register_error(elgg_echo("tidypics:phototagging:error"));
forward($_SERVER['HTTP_REFERER']);
}
+ $new_word_tag = false;
if ($user_id != 0) {
$relationships_type = 'user';
$value = $user_id;
} else {
$relationships_type = 'word';
$value = $word;
+
+ // check to see if the photo has this tag and add if not
+ if (!is_array($image->tags)) {
+ if ($image->tags != $word) {
+ $new_word_tag = true;
+ $tagarray = $image->tags . ',' . $word;
+ $tagarray = string_to_tag_array($tagarray);
+ }
+ } else {
+ if (!in_array($word, $image->tags)) {
+ $new_word_tag = true;
+ $tagarray = $image->tags;
+ $tagarray[] = $word;
+ }
+ }
+ }
+
+ // add new tag now so it is available in search
+ if ($new_word_tag) {
+ $image->clearMetadata('tags');
+ $image->tags = $tagarray;
}
// test for empty tag
@@ -49,10 +67,10 @@
//Save annotation
if ($image->annotate('phototag', serialize($tag), $access_id, $owner_id)) {
- system_message(elgg_echo("image:tagged"));
+ system_message(elgg_echo("tidypics:phototagging:success"));
}
forward($_SERVER['HTTP_REFERER']);
-?> \ No newline at end of file
+?>