From e22a0309230b0bb3fc15347a22ada9ef5d86e04a Mon Sep 17 00:00:00 2001 From: Dominik Blunk Date: Thu, 3 Jun 2010 19:26:34 +0200 Subject: [PATCH 10/19] Plugin Drag and Drop File Upload (Java Applet) implemented - Part 2 --- .gitignore | 16 +- bug_file_upload_inc.php | 10 + core/events_inc.php | 4 + core/file_api.php | 1 + .../DragAndDropFileUploadJavaApplet.php | 192 +++++++++++++++++-- .../DragAndDropFileUploadJavaApplet/files/dnd.jar | Bin 0 -> 75584 bytes .../files/dndlite.jar | Bin 0 -> 56433 bytes .../files/dndplus.jar | Bin 0 -> 94460 bytes .../lang/strings_english.txt | 32 ++-- .../pages/applet_properties.php | 197 ++++++++++++++++++++ .../pages/config.php | 48 +++--- .../pages/config_edit.php | 57 +++--- 12 files changed, 466 insertions(+), 91 deletions(-) create mode 100644 plugins/DragAndDropFileUploadJavaApplet/files/dnd.jar create mode 100644 plugins/DragAndDropFileUploadJavaApplet/files/dndlite.jar create mode 100644 plugins/DragAndDropFileUploadJavaApplet/files/dndplus.jar create mode 100644 plugins/DragAndDropFileUploadJavaApplet/pages/applet_properties.php diff --git a/bug_file_upload_inc.php b/bug_file_upload_inc.php index 9cc9386..ba60acd 100644 --- a/bug_file_upload_inc.php +++ b/bug_file_upload_inc.php @@ -31,6 +31,9 @@ } $t_max_file_size = (int)min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) ); + + # start output buffering + ob_start( ); ?>
@@ -77,3 +80,10 @@ EVENT_TYPE_EXECUTE, 'EVENT_TAG_DETACHED' => EVENT_TYPE_EXECUTE, + # File events + 'EVENT_FILE_UPLOAD_FORM' => EVENT_TYPE_CHAIN, + 'EVENT_FILE_ADDED' => EVENT_TYPE_EXECUTE, + # Email notification events 'EVENT_NOTIFY_USER_INCLUDE' => EVENT_TYPE_DEFAULT, 'EVENT_NOTIFY_USER_EXCLUDE' => EVENT_TYPE_DEFAULT, diff --git a/core/file_api.php b/core/file_api.php index 4729d4d..6fafe2b 100644 --- a/core/file_api.php +++ b/core/file_api.php @@ -726,6 +726,7 @@ function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc # log new bug history_log_event_special( $p_bug_id, FILE_ADDED, $t_file_name ); } + event_signal('EVENT_FILE_ADDED', $p_file); } # -------------------- -- 1.7.0.2.msysgit.0 From 5e71ef30376329e49670efaadb9ef32642488b0c Mon Sep 17 00:00:00 2001 From: Dominik Blunk Date: Fri, 4 Jun 2010 11:33:32 +0200 Subject: [PATCH 11/19] Drag and Drop File Upload Plugin finished so far... --- core/html_api.php | 2 +- .../DragAndDropFileUploadJavaApplet.php | 36 ++++++--------- .../lang/strings_english.txt | 1 + .../pages/account_plugin_prefs.php | 47 ++++++++++++++++++++ .../pages/account_plugin_prefs_update.php | 19 ++++++++ .../pages/config.php | 4 +- .../pages/config_edit.php | 39 ---------------- .../pages/config_update.php | 39 ++++++++++++++++ .../DragAndDropFileUploadJavaApplet/pages/foo.php | 17 ------- 9 files changed, 123 insertions(+), 81 deletions(-) create mode 100644 plugins/DragAndDropFileUploadJavaApplet/pages/account_plugin_prefs.php create mode 100644 plugins/DragAndDropFileUploadJavaApplet/pages/account_plugin_prefs_update.php delete mode 100644 plugins/DragAndDropFileUploadJavaApplet/pages/config_edit.php create mode 100644 plugins/DragAndDropFileUploadJavaApplet/pages/config_update.php delete mode 100644 plugins/DragAndDropFileUploadJavaApplet/pages/foo.php diff --git a/core/html_api.php b/core/html_api.php index 61be4d4..dea70ae 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -1116,7 +1116,7 @@ function print_account_menu( $p_page = '' ) { } # Plugin / Event added options - $t_event_menu_options = event_signal( 'EVENT_MENU_ACCOUNT' ); + $t_event_menu_options = event_signal( 'EVENT_MENU_ACCOUNT', $p_page ); $t_menu_options = array(); foreach( $t_event_menu_options as $t_plugin => $t_plugin_menu_options ) { foreach( $t_plugin_menu_options as $t_callback => $t_callback_menu_options ) { -- 1.7.0.2.msysgit.0 From bc68ab67ca1dd81dcd9ab7270ac34604b93b82d4 Mon Sep 17 00:00:00 2001 From: Dominik Blunk Date: Fri, 4 Jun 2010 14:10:51 +0200 Subject: [PATCH 14/19] Enabled multiple files upload --- bug_file_add.php | 21 ++++++++++++++++++- .../DragAndDropFileUploadJavaApplet.php | 13 +----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/bug_file_add.php b/bug_file_add.php index ae768da..524ab64 100644 --- a/bug_file_add.php +++ b/bug_file_add.php @@ -52,8 +52,25 @@ access_ensure_bug_level( config_get( 'upload_bug_file_threshold' ), $f_bug_id ); - file_add( $f_bug_id, $f_file, 'bug' ); - + if ( is_array( $f_file['tmp_name'] ) ) { + # multiple files uploaded + for ( $i = 0; $i < count( $f_file['tmp_name'] ); $i++ ) { + $t_single_file_data = array( 'name' => $f_file['name'][$i], + 'type' => $f_file['type'][$i], + 'tmp_name' => $f_file['tmp_name'][$i], + 'error' => $f_file['error'][$i], + 'size' => $f_file['size'][$i] + ); + file_add( $f_bug_id, $t_single_file_data, 'bug' ); + } + # because multiple files are only possible with Drag And Drop File Upload Java Applet Plugin + # we quit here (response is sent by hooked event EVENT_FILE_ADDED) + exit(); + } + else { + file_add( $f_bug_id, $f_file, 'bug' ); + } + form_security_purge( 'bug_file_add' ); # Determine which view page to redirect back to. -- 1.7.0.2.msysgit.0