]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
handling new album in ajax upload code now
authorCash Costello <cash.costello@gmail.com>
Sat, 30 Oct 2010 14:49:14 +0000 (14:49 +0000)
committerCash Costello <cash.costello@gmail.com>
Sat, 30 Oct 2010 14:49:14 +0000 (14:49 +0000)
actions/ajax_upload_complete.php [new file with mode: 0644]
start.php
views/default/tidypics/forms/ajax_upload.php

diff --git a/actions/ajax_upload_complete.php b/actions/ajax_upload_complete.php
new file mode 100644 (file)
index 0000000..4fc9606
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/**
+ * A batch is complete so check if this is first upload to album
+ *
+ */
+
+$album_guid = (int) get_input('album_guid');
+
+$album = get_entity($album_guid);
+if (!$album) {
+       exit;
+}
+
+if ($album->new_album == TP_NEW_ALBUM) {
+       $album->new_album = TP_OLD_ALBUM;
+
+       // we throw the notification manually here so users are not told about the new album until there
+       // is at least a few photos in it
+       object_notifications('create', 'object', $album);
+
+       add_to_river('river/object/album/create', 'create', $album->owner_guid, $album->guid);
+}
+
+exit;
\ No newline at end of file
index a50f23c57cc689629d18e9893e5cc4b4b0e76dd3..c44bc9f1e503280fee8edf922a4f1a95107fc209 100644 (file)
--- a/start.php
+++ b/start.php
@@ -464,6 +464,7 @@ register_elgg_event_handler('pagesetup', 'system', 'tidypics_adminmenu');
 // Register actions
 register_action("tidypics/upload", false, $CONFIG->pluginspath . "tidypics/actions/upload.php");
 register_action("tidypics/ajax_upload", true, $CONFIG->pluginspath . "tidypics/actions/ajax_upload.php");
+register_action("tidypics/ajax_upload_complete", true, $CONFIG->pluginspath . "tidypics/actions/ajax_upload_complete.php");
 register_action("tidypics/addalbum", false, $CONFIG->pluginspath. "tidypics/actions/addalbum.php");
 register_action("tidypics/edit", false, $CONFIG->pluginspath. "tidypics/actions/edit.php");
 register_action("tidypics/delete", false, $CONFIG->pluginspath. "tidypics/actions/delete.php");
index fb9060a50ae31bb97c1adb706b1898f3de22c42c..912d1c03e6554b1a60077875e6579f0bdf9cb60c 100644 (file)
@@ -10,6 +10,10 @@ $token = generate_action_token($ts);
 
 $batch = time();
 
+$basic_uploader_url = current_page_url() . '/basic';
+
+$upload_endpoint_url = "{$vars['url']}action/tidypics/ajax_upload/";
+$upload_complete_url = "{$vars['url']}action/tidypics/ajax_upload_complete/";
 
 $maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics');
 if (!$maxfilesize) {
@@ -33,8 +37,6 @@ if ($quota) {
        }
 }
 
-$basic_uploader_url = current_page_url() . '/basic';
-
 ?>
 
 <div class="contentWrapper">
@@ -69,7 +71,7 @@ $basic_uploader_url = current_page_url() . '/basic';
 
 $("#uploadify").uploadify({
        'uploader'     : '<?php echo $vars['url']; ?>mod/tidypics/vendors/uploadify/uploadify.swf',
-       'script'       : '<?php echo $vars['url']; ?>action/tidypics/ajax_upload/',
+       'script'       : '<?php echo $upload_endpoint_url; ?>',
        'scriptData'   : {
                                                'album_guid'   : '<?php echo $album->guid; ?>',
                                                '__elgg_token' : '<?php echo $token; ?>',
@@ -101,6 +103,14 @@ $("#uploadify").uploadify({
        },
        'onAllComplete' : function() {
                $("#tidypics_describe_button").removeClass('tidypics_disable');
+               $.post(
+                       '<?php echo $upload_complete_url; ?>',
+                       { 
+                               album_guid   : '<?php echo $album->guid; ?>',
+                               __elgg_token : '<?php echo $token; ?>',
+                               __elgg_ts    : '<?php echo $ts; ?>'
+                       }
+               );
        },
        'onCancel'      : function(event, queueID, fileObj, data) {
                if (data.fileCount == 0) {