@@ -646,10 +646,11 @@ function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc
646
646
$ t_file_path = config_get ( 'absolute_path_default_upload_folder ' );
647
647
} else {
648
648
$ t_file_path = project_get_field ( $ t_project_id , 'file_path ' );
649
- if ( $ t_file_path == '' ) {
649
+ if ( is_blank ( $ t_file_path ) ) {
650
650
$ t_file_path = config_get ( 'absolute_path_default_upload_folder ' );
651
651
}
652
652
}
653
+
653
654
$ c_file_path = db_prepare_string ( $ t_file_path );
654
655
$ c_new_file_name = db_prepare_string ( $ t_file_name );
655
656
@@ -848,26 +849,26 @@ function file_get_extension( $p_filename ) {
848
849
}
849
850
850
851
/**
851
- *
852
+ *
852
853
* Copies all attachments from the source bug to the destination bug
853
- *
854
+ *
854
855
* <p>Does not perform history logging and does not perform access checks.</p>
855
- *
856
+ *
856
857
* @param int $p_source_bug_id
857
858
* @param int $p_dest_bug_id
858
859
*/
859
860
function file_copy_attachments ( $ p_source_bug_id , $ p_dest_bug_id ) {
860
-
861
+
861
862
$ t_mantis_bug_file_table = db_get_table ( 'mantis_bug_file_table ' );
862
-
863
+
863
864
$ query = 'SELECT * FROM ' . $ t_mantis_bug_file_table . ' WHERE bug_id = ' . db_param ();
864
865
$ result = db_query_bound ( $ query , Array ( $ p_source_bug_id ) );
865
866
$ t_count = db_num_rows ( $ result );
866
-
867
+
867
868
$ t_bug_file = array ();
868
869
for ( $ i = 0 ;$ i < $ t_count ;$ i ++ ) {
869
870
$ t_bug_file = db_fetch_array ( $ result );
870
-
871
+
871
872
# prepare the new diskfile name and then copy the file
872
873
$ t_file_path = dirname ( $ t_bug_file ['folder ' ] );
873
874
$ t_new_diskfile_name = $ t_file_path . file_generate_unique_name ( 'bug- ' . $ t_bug_file ['filename ' ], $ t_file_path );
@@ -876,7 +877,7 @@ function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
876
877
copy ( $ t_bug_file ['diskfile ' ], $ t_new_diskfile_name );
877
878
chmod ( $ t_new_diskfile_name , config_get ( 'attachments_file_permissions ' ) );
878
879
}
879
-
880
+
880
881
$ query = "INSERT INTO $ t_mantis_bug_file_table
881
882
( bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content )
882
883
VALUES ( " . db_param () . ",
@@ -891,4 +892,4 @@ function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
891
892
" . db_param () . "); " ;
892
893
db_query_bound ( $ query , Array ( $ p_dest_bug_id , $ t_bug_file ['title ' ], $ t_bug_file ['description ' ], $ t_new_diskfile_name , $ t_new_file_name , $ t_bug_file ['folder ' ], $ t_bug_file ['filesize ' ], $ t_bug_file ['file_type ' ], $ t_bug_file ['date_added ' ], $ t_bug_file ['content ' ] ) );
893
894
}
894
- }
895
+ }
0 commit comments