logo       
Google Custom Search
    AddThis Social Bookmark Button

Recently Viewed: audio.musicbrai...    enbd.general/20...    ietf.idr/2002-0...    java.ant-contri...    gnu.make.genera...    qplus.devel/200...    video.freevo.cv...    os.netbsd.ports...    yellowdog.gener...    xfree86.cvs/200...    search.nutch.us...    freedesktop.xse...    programming.swi...    capabilities.ge...    telephony.pbx.a...    mail.sylpheed.c...    db.firebase.por...    boot-loaders.u-...    recreation.radi...    netbsd.bugs/200...    web.zope.plone....    user-groups.lin...   

mantisbt/core file_api.php,1.56,1.57 project_api.php,1.61,1.62: msg#00127

Subject: mantisbt/core file_api.php,1.56,1.57 project_api.php,1.61,1.62
Update of /cvsroot/mantisbt/mantisbt/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26184/core

Modified Files:
        file_api.php project_api.php 
Log Message:
fix for  0004615: Issues can have two attachments with the same display name
added check for filename uniqueness at bug and project level


Index: file_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/file_api.php,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- file_api.php        21 Sep 2004 18:02:28 -0000      1.56
+++ file_api.php        28 Sep 2004 00:56:13 -0000      1.57
@@ -449,14 +449,14 @@
        function file_generate_unique_name( $p_seed , $p_filepath ) {
                do {
                        $t_string = file_generate_name( $p_seed );
-               } while ( !file_is_name_unique( $t_string , $p_filepath ) );
+               } while ( !diskfile_is_name_unique( $t_string , $p_filepath ) );
 
                return $t_string;
        }
 
        # --------------------
-       # Return true if the file name identifier is unique, false otherwise
-       function file_is_name_unique( $p_name , $p_filepath ) {
+       # Return true if the diskfile name identifier is unique, false otherwise
+       function diskfile_is_name_unique( $p_name , $p_filepath ) {
                $t_file_table = config_get( 'mantis_bug_file_table' );
 
                $c_name = db_prepare_string( $p_filepath . $p_name );
@@ -475,6 +475,27 @@
        }
 
        # --------------------
+       # Return true if the file name identifier is unique, false otherwise
+       function file_is_name_unique( $p_name, $p_bug_id ) {
+               $t_file_table = config_get( 'mantis_bug_file_table' );
+
+               $c_name = db_prepare_string( $p_name );
+               $c_bug = db_prepare_string( $p_bug_id );
+
+               $query = "SELECT COUNT(*)
+                                 FROM $t_file_table
+                                 WHERE filename='$c_name' and bug_id=$c_bug";
+               $result = db_query( $query );
+               $t_count = db_result( $result );
+
+               if ( $t_count > 0 ) {
+                       return false;
+               } else {
+                       return true;
+               }
+       }
+
+       # --------------------
        function file_add( $p_bug_id, $p_tmp_file, $p_file_name, 
$p_file_type='' ) {
                $c_bug_id               = db_prepare_int( $p_bug_id );
                $c_file_type    = db_prepare_string( $p_file_type );
@@ -485,7 +506,13 @@
 
                if ( !file_type_check( $p_file_name ) ) {
                        trigger_error( ERROR_FILE_NOT_ALLOWED, ERROR );
-               } else if ( is_uploaded_file( $p_tmp_file ) ) {
+               }  
+
+               if ( !file_is_name_unique( $p_file_name, $p_bug_id ) ) {
+                       trigger_error( ERROR_DUPLICATE_FILE, ERROR );
+               }  
+
+               if ( is_uploaded_file( $p_tmp_file ) ) {
                        $t_project_id   = bug_get_field( $p_bug_id, 
'project_id' );
                        $t_bug_id               = bug_format_id( $p_bug_id );
 

Index: project_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/project_api.php,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- project_api.php     27 Sep 2004 12:45:15 -0000      1.61
+++ project_api.php     28 Sep 2004 00:56:14 -0000      1.62
@@ -647,4 +647,26 @@
                $t_padding = config_get( 'display_project_padding' );
                return( str_pad( $p_project_id, $t_padding, '0', STR_PAD_LEFT ) 
);
        }
+
+               # --------------------
+       # Return true if the file name identifier is unique, false otherwise
+       function project_file_is_name_unique( $p_name ) {
+               $t_file_table = config_get( 'mantis_project_file_table' );
+
+               $c_name = db_prepare_string( $p_name );
+
+               $query = "SELECT COUNT(*)
+                                 FROM $t_file_table
+                                 WHERE filename='$c_name'";
+               $result = db_query( $query );
+               $t_count = db_result( $result );
+
+               if ( $t_count > 0 ) {
+                       return false;
+               } else {
+                       return true;
+               }
+       }
+
+
 ?>



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>