diff options
author | Cash Costello <cash.costello@gmail.com> | 2012-07-13 22:35:35 -0400 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2012-07-13 22:35:35 -0400 |
commit | e790d7ec5d74c5a2279d6bd73e2508eb18209da9 (patch) | |
tree | 38ed43f391038d641372e8887bcc9b68b9e55a15 /actions | |
parent | f611a0505343629bb3c353647334f039bbed48af (diff) | |
parent | 0ec5f4f4f8d9011e460d17156ddf20d96483600d (diff) | |
download | elgg-e790d7ec5d74c5a2279d6bd73e2508eb18209da9.tar.gz elgg-e790d7ec5d74c5a2279d6bd73e2508eb18209da9.tar.bz2 |
Added deleting photo tags
Diffstat (limited to 'actions')
-rw-r--r-- | actions/deletetag.php | 54 | ||||
-rw-r--r-- | actions/photos/image/untag.php | 24 |
2 files changed, 24 insertions, 54 deletions
diff --git a/actions/deletetag.php b/actions/deletetag.php deleted file mode 100644 index 97c1081f8..000000000 --- a/actions/deletetag.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * Tidypics Delete Photo Tag - * - */ - -gatekeeper(); -action_gatekeeper(); - -$image_guid = get_input('image_guid'); -$tags = get_input('tags'); - - -if ($image_guid == 0) { - register_error(elgg_echo("tidypics:phototagging:error")); - forward($_SERVER['HTTP_REFERER']); -} - -$image = get_entity($image_guid); -if (!$image) { - register_error(elgg_echo("tidypics:phototagging:error")); - forward($_SERVER['HTTP_REFERER']); -} - -foreach ($tags as $id => $value) { - // delete normal tag if it exists - if (is_array($image->tags)) { - $index = array_search($value, $image->tags); - if ($index !== false) { - $tagarray = $image->tags; - unset($tagarray[$index]); - $image->clearMetadata('tags'); - $image->tags = $tagarray; - } - } else { - if ($value === $image->tags) { - $image->clearMetadata('tags'); - } - } - - // delete relationship if this tag is a user - $annotation = get_annotation($id); - $photo_tag = unserialize($annotation->value); - if ($photo_tag->type == 'user') { - remove_entity_relationship($photo_tag->value, 'phototag', $image_guid); - } - - // delete the photo tag annotation - delete_annotation($id); -} - -system_message(elgg_echo("tidypics:deletetag:success")); - -forward($_SERVER['HTTP_REFERER']); diff --git a/actions/photos/image/untag.php b/actions/photos/image/untag.php new file mode 100644 index 000000000..012f98930 --- /dev/null +++ b/actions/photos/image/untag.php @@ -0,0 +1,24 @@ +<?php +/** + * Remove photo tag action + */ + +$annotation = get_annotation(get_input('annotation_id')); + +if (!$annotation instanceof ElggAnnotation || $annotation->name != 'phototag') { + register_error(elgg_echo("tidypics:phototagging:delete:error")); + forward(REFERER); +} + +if (!$annotation->canEdit()) { + register_error(elgg_echo("tidypics:phototagging:delete:error")); + forward(REFERER); +} + +if ($annotation->delete()) { + system_message(elgg_echo("tidypics:phototagging:delete:success")); +} else { + system_message(elgg_echo("tidypics:phototagging:delete:error")); +} + +forward(REFERER); |