From 991bfbb05dbfe4919f1ef1be4feb359f4815a77c Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 9 May 2009 15:09:28 +0000 Subject: added a check so that normal tags are created for photo tags that are not users --- actions/addtag.php | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'actions') 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 +?> -- cgit v1.2.3