aboutsummaryrefslogtreecommitdiff
path: root/actions/edit.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/edit.php
parent791ec4925346cb38ecca9a2f2574b012ab64a88a (diff)
downloadelgg-73403645808a81425381f43c25e0ea2c92705312.tar.gz
elgg-73403645808a81425381f43c25e0ea2c92705312.tar.bz2
first go at brining tidypics up to code standards
Diffstat (limited to 'actions/edit.php')
-rw-r--r--actions/edit.php135
1 files changed, 68 insertions, 67 deletions
diff --git a/actions/edit.php b/actions/edit.php
index cdf9420b2..db6e26ab9 100644
--- a/actions/edit.php
+++ b/actions/edit.php
@@ -1,81 +1,82 @@
<?php
- /**
- * Tidypics edit album/image action
- *
- */
-
- // Make sure we're logged in
- gatekeeper();
+/**
+ * Tidypics edit album/image action
+ *
+ */
- // Get input data
- $guid = (int) get_input('guid'); // guid of image or album
- $title = get_input('tidypicstitle');
- $body = get_input('tidypicsbody');
- $access = get_input('access_id');
- $tags = get_input('tidypicstags');
- $subtype = get_input('subtype');
- $cover = get_input('cover');
- if (is_array($cover)) $cover = $cover[0];
-
- $container_guid = get_input('container_guid');
+// Make sure we're logged in
+gatekeeper();
- // Make sure we actually have permission to edit
- $entity = get_entity($guid);
- if (!$entity->canEdit()) {
- forward();
- }
+// Get input data
+$guid = (int) get_input('guid'); // guid of image or album
+$title = get_input('tidypicstitle');
+$body = get_input('tidypicsbody');
+$access = get_input('access_id');
+$tags = get_input('tidypicstags');
+$subtype = get_input('subtype');
+$cover = get_input('cover');
+if (is_array($cover)) {
+ $cover = $cover[0];
+}
- // Get owning user/group
- $owner = get_entity($entity->getOwner());
+$container_guid = get_input('container_guid');
- // change access only if access is different from current
- if ($subtype == 'album' && $entity->access_id != $access) {
- $entity->access_id = $access;
-
- //get images from album and update access on image entities
- $images = get_entities("object","image", $guid, '', 999, '', false);
- foreach ($images as $im) {
- $im->access_id = $access;
- $im->save();
- }
- }
+// Make sure we actually have permission to edit
+$entity = get_entity($guid);
+if (!$entity->canEdit()) {
+ forward();
+}
+// Get owning user/group
+$owner = get_entity($entity->getOwner());
- // Set its title and description appropriately
- $entity->title = $title;
- $entity->description = $body;
+// change access only if access is different from current
+if ($subtype == 'album' && $entity->access_id != $access) {
+ $entity->access_id = $access;
- // Before we can set metadata, we need to save the entity
- if (!$entity->save()) {
- register_error(elgg_echo("album:error"));
- $entity->delete();
- forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page
+ //get images from album and update access on image entities
+ $images = get_entities("object","image", $guid, '', 999, '', false);
+ foreach ($images as $im) {
+ $im->access_id = $access;
+ $im->save();
}
+}
- // Now let's add tags
- $tagarray = string_to_tag_array($tags);
- $entity->clearMetadata('tags');
- if (is_array($tagarray)) {
- $entity->tags = $tagarray;
- }
- //if cover meta is sent from image save as metadata
- if ($subtype == 'image' && $cover == elgg_echo('album:cover')) {
- $album = get_entity($container_guid);
- $album->cover = $entity->guid;
- }
+// Set its title and description appropriately
+$entity->title = $title;
+$entity->description = $body;
- // Success message
- if ($subtype == 'album') {
- system_message(elgg_echo("album:edited"));
- // plugins can register to be told when a Tidypics album has been updated
- trigger_elgg_event('update', 'tp_album', $entity);
- } else {
- system_message(elgg_echo('images:edited'));
- // plugins can register to be told when a Tidypics image has been updated
- trigger_elgg_event('update', 'tp_image', $entity);
- }
+// Before we can set metadata, we need to save the entity
+if (!$entity->save()) {
+ register_error(elgg_echo("album:error"));
+ $entity->delete();
+ forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page
+}
+
+// Now let's add tags
+$tagarray = string_to_tag_array($tags);
+$entity->clearMetadata('tags');
+if (is_array($tagarray)) {
+ $entity->tags = $tagarray;
+}
+
+//if cover meta is sent from image save as metadata
+if ($subtype == 'image' && $cover == elgg_echo('album:cover')) {
+ $album = get_entity($container_guid);
+ $album->cover = $entity->guid;
+}
+
+// Success message
+if ($subtype == 'album') {
+ system_message(elgg_echo("album:edited"));
+ // plugins can register to be told when a Tidypics album has been updated
+ trigger_elgg_event('update', 'tp_album', $entity);
+} else {
+ system_message(elgg_echo('images:edited'));
+ // plugins can register to be told when a Tidypics image has been updated
+ trigger_elgg_event('update', 'tp_image', $entity);
+}
- forward($entity->getURL());
-?>
+forward($entity->getURL());