From 5cc8de829c0a7b86c8df27293f4825d0e340d592 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Fri, 16 Mar 2012 22:51:12 -0700 Subject: Fixes #14. Fixed uploadify. --- actions/photos/image/ajax_upload_complete.php | 74 +++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 actions/photos/image/ajax_upload_complete.php (limited to 'actions/photos/image/ajax_upload_complete.php') diff --git a/actions/photos/image/ajax_upload_complete.php b/actions/photos/image/ajax_upload_complete.php new file mode 100644 index 000000000..6d398b3aa --- /dev/null +++ b/actions/photos/image/ajax_upload_complete.php @@ -0,0 +1,74 @@ + 'object', + 'subtype' => 'image', + 'metadata_names' => 'batch', + 'metadata_values' => $batch, + 'limit' => 0 +); + +$images = elgg_get_entities_from_metadata($params); +if ($images) { + // Create a new batch object to contain these photos + $batch = new ElggObject(); + $batch->subtype = "tidypics_batch"; + $batch->access_id = ACCESS_PUBLIC; + $batch->container_guid = $album->guid; + + if ($batch->save()) { + foreach ($images as $image) { + add_entity_relationship($image->guid, "belongs_to_batch", $batch->getGUID()); + } + } +} else { + // @todo some sort of message to edit them manually. + exit; +} + +// "added images to album" river +if ($img_river_view == "batch" && $album->new_album == false) { + add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID()); +} + +// "created album" river +if ($album->new_album) { + $album->new_album = false; + $album->first_upload = true; + + add_to_river('river/object/album/create', 'create', $album->getOwnerGUID(), $album->getGUID()); + + // "created album" notifications + // we throw the notification manually here so users are not told about the new album until + // there are at least a few photos in it + if ($album->shouldNotify()) { + object_notifications('create', 'object', $album); + $album->last_notified = time(); + } +} else { + // "added image to album" notifications + if ($album->first_upload) { + $album->first_upload = false; + } + + if ($album->shouldNotify()) { + object_notifications('create', 'object', $album); + $album->last_notified = time(); + } +} + +echo json_encode(array('batch_guid' => $batch->getGUID())); +exit; \ No newline at end of file -- cgit v1.2.3