aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-05-09 15:09:28 +0000
committerCash Costello <cash.costello@gmail.com>2009-05-09 15:09:28 +0000
commit991bfbb05dbfe4919f1ef1be4feb359f4815a77c (patch)
tree15ec0329fb8c07adb83b5970ba5d1476251881d5 /actions
parent40c43b204903a03c63f7b9911b27717547ff5aa5 (diff)
downloadelgg-991bfbb05dbfe4919f1ef1be4feb359f4815a77c.tar.gz
elgg-991bfbb05dbfe4919f1ef1be4feb359f4815a77c.tar.bz2
added a check so that normal tags are created for photo tags that are not users
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
+?>