aboutsummaryrefslogtreecommitdiff
path: root/actions/deletetag.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2010-07-25 02:01:36 +0000
committerCash Costello <cash.costello@gmail.com>2010-07-25 02:01:36 +0000
commit73403645808a81425381f43c25e0ea2c92705312 (patch)
tree83fb73e9a122054f6f4c2e1c44e399572ee13e28 /actions/deletetag.php
parent791ec4925346cb38ecca9a2f2574b012ab64a88a (diff)
downloadelgg-73403645808a81425381f43c25e0ea2c92705312.tar.gz
elgg-73403645808a81425381f43c25e0ea2c92705312.tar.bz2
first go at brining tidypics up to code standards
Diffstat (limited to 'actions/deletetag.php')
-rw-r--r--actions/deletetag.php97
1 files changed, 47 insertions, 50 deletions
diff --git a/actions/deletetag.php b/actions/deletetag.php
index becf1fedb..97c1081f8 100644
--- a/actions/deletetag.php
+++ b/actions/deletetag.php
@@ -1,57 +1,54 @@
<?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']);
- }
+/**
+ * Tidypics Delete Photo Tag
+ *
+ */
- $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');
- }
+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;
}
-
- // 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);
+ } else {
+ if ($value === $image->tags) {
+ $image->clearMetadata('tags');
}
-
- // delete the photo tag annotation
- delete_annotation($id);
}
-
- system_message(elgg_echo("tidypics:deletetag:success"));
- forward($_SERVER['HTTP_REFERER']);
+ // 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']);