aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/addtag.php34
-rw-r--r--languages/en.php2
2 files changed, 28 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
+?>
diff --git a/languages/en.php b/languages/en.php
index b0f358910..e3631532d 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -60,6 +60,8 @@
'image:tagthisphoto' => 'Tag this photo',
'image:actiontag' => 'Tag',
'image:inthisphoto' => 'In this photo',
+ 'tidypics:phototagging:success' => 'Photo tag was successfully added',
+ 'tidypics:phototagging:error' => 'Unexpected error occurred during tagging',
//widgets