aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/ajax_upload_complete.php23
-rw-r--r--actions/upload.php22
2 files changed, 38 insertions, 7 deletions
diff --git a/actions/ajax_upload_complete.php b/actions/ajax_upload_complete.php
index 0912854a3..b66b563e3 100644
--- a/actions/ajax_upload_complete.php
+++ b/actions/ajax_upload_complete.php
@@ -21,6 +21,29 @@ if ($album->new_album == TP_NEW_ALBUM) {
add_to_river('river/object/album/create', 'create', $album->owner_guid, $album->guid);
}
+$params = array(
+ 'type' => 'object',
+ 'subtype' => 'image',
+ 'metadata_names' => 'batch',
+ 'metadata_values' => get_input('batch'),
+);
+$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());
+ }
+ if (get_plugin_setting('img_river_view', 'tidypics') == "batch") {
+ add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
+ }
+ }
+}
+
// plugins can register to be told when a Tidypics album has had images added
trigger_elgg_event('upload', 'tp_album', $album);
diff --git a/actions/upload.php b/actions/upload.php
index b3ad9ebc3..f2b626f01 100644
--- a/actions/upload.php
+++ b/actions/upload.php
@@ -120,11 +120,6 @@ foreach($_FILES as $key => $sent_file) {
$file->extractExifData();
$file->saveThumbnails($image_lib);
- //keep one file handy so we can add a notice to the river if single image option selected
- if (!$file_for_river) {
- $file_for_river = $file;
- }
-
array_push($uploaded_images, $file->guid);
// plugins can register to be told when a new image has been uploaded
@@ -171,11 +166,24 @@ if (count($not_uploaded) > 0) {
system_message(elgg_echo('tidypics:upl_success'));
}
+if (count($uploaded_images)) {
+ // Create a new batch object to contain these photos
+ $batch = new ElggObject();
+ $batch->subtype = "tidypics_batch";
+ $batch->access_id = $access_id;
+ $batch->container_guid = $album_guid;
-if (count($uploaded_images) && $img_river_view == "1") {
- add_to_river('river/object/image/create', 'create', $file_for_river->getObjectOwnerGUID(), $file_for_river->getGUID());
+ if ($batch->save()) {
+ foreach ($uploaded_images as $uploaded_guid) {
+ add_entity_relationship($uploaded_guid, "belongs_to_batch", $batch->getGUID());
+ }
+ if ($img_river_view == "batch") {
+ add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
+ }
+ }
}
+
if (count($uploaded_images) > 0) {
$album->prependImageList($uploaded_images);
}