Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5df3d933f145
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cba1af4b2365
Choose a head ref
  • 6 commits
  • 5 files changed
  • 1 contributor

Commits on Sep 19, 2012

  1. Cloning issues with attachments fails after upload folder changed

    With attachments stored on disk, if the project's upload directory
    changes and the files are moved to the new location, it is no longer
    possible to clone issues.
    
    The file_copy_attachments() function was modified to use the same logic
    as elsewhere in MantisBT, i.e. rely on file_normalize_attachment_path()
    to determine the attachment's path.
    
    Fixes #14718
    dregad committed Sep 19, 2012
    Copy the full SHA
    7f3b0e7 View commit details

Commits on Sep 20, 2012

  1. Force validation of upload path if file_upload_method != DATABASE

    Prior to this, the upload path would not be checked if it was empty
    (ie. defaulting to $g_absolute_path_default_upload_folder),
    which could cause issues if that directory was missing or read-only.
    
    Checking this early allows catching any errors before users perform
    actual operations on file attachments.
    
    Fixes #14723
    dregad committed Sep 20, 2012

    Verified

    This commit was signed with the committer’s verified signature.
    vcunat Vladimír Čunát
    Copy the full SHA
    7e27a16 View commit details
  2. Hide file upload path on project create page if storage is DB

    The logic implemented in 7aa07d8 for
    manage_proj_edit_page.php also applies to manage_proj_create_page.php.
    
    Fixes #14700
    dregad committed Sep 20, 2012
    Copy the full SHA
    45e7b99 View commit details
  3. Fix inconsistent behavior of upload path field hiding

    config_get() would return the file upload method for the current
    project, instead of the one for the project being edited.
    
    Use of $g_project_override for expected behavior.
    
    Fixes #14700
    dregad committed Sep 20, 2012
    Copy the full SHA
    8daa086 View commit details
  4. Make Manage Project Create and Edit pages consistent

    The following changes were made:
    
     - Display the fields in the same order
     - Make the fields identical length
     - replace uses of class="row-X" with helper_alternate_class() calls
     - Display the "required" star next to project name
     - Added comments
     - Use identical variable names
     - Align submit buttons the same way
    
    Fixes #14725
    dregad committed Sep 20, 2012
    Copy the full SHA
    0b5f7bc View commit details
  5. Fix config_get behavior with $g_project_override = ALL_PROJECTS

    Fixes #14724, affects #14700
    dregad committed Sep 20, 2012
    Copy the full SHA
    cba1af4 View commit details
Showing with 89 additions and 53 deletions.
  1. +1 −1 core/config_api.php
  2. +16 −4 core/file_api.php
  3. +7 −2 core/project_api.php
  4. +51 −34 manage_proj_create_page.php
  5. +14 −12 manage_proj_edit_page.php
2 changes: 1 addition & 1 deletion core/config_api.php
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ function config_get( $p_option, $p_default = null, $p_user = null, $p_project =
# @@ debug @@ if ($t_bypass_lookup) { echo "bp=$p_option match=$t_match_pattern <br />"; }

if( !$t_bypass_lookup ) {
if( $g_project_override != null && $p_project == null ) {
if( $g_project_override !== null && $p_project === null ) {
$p_project = $g_project_override;
}
# @@ debug @@ if ( ! db_is_connected() ) { echo "no db "; }
20 changes: 16 additions & 4 deletions core/file_api.php
Original file line number Diff line number Diff line change
@@ -865,18 +865,30 @@ function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
$result = db_query_bound( $query, Array( $p_source_bug_id ) );
$t_count = db_num_rows( $result );

$t_project_id = bug_get_field( $p_source_bug_id, 'project_id' );

$t_bug_file = array();
for( $i = 0;$i < $t_count;$i++ ) {
$t_bug_file = db_fetch_array( $result );

# prepare the new diskfile name and then copy the file
$t_file_path = $t_bug_file['folder'];
$t_source_file = $t_bug_file['folder'] . $t_bug_file['diskfile'];
if(( config_get( 'file_upload_method' ) == DISK ) ) {
$t_source_file = file_normalize_attachment_path( $t_source_file, $t_project_id );
$t_file_path = dirname( $t_source_file ) . DIRECTORY_SEPARATOR;
} else {
$t_file_path = $t_bug_file['folder'];
}
$t_new_diskfile_name = file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path );
$t_new_diskfile_location = $t_file_path . $t_new_diskfile_name;
$t_new_file_name = file_get_display_name( $t_bug_file['filename'] );
if(( config_get( 'file_upload_method' ) == DISK ) ) {
copy( $t_file_path.$t_bug_file['diskfile'], $t_new_diskfile_location );
chmod( $t_new_diskfile_location, config_get( 'attachments_file_permissions' ) );
# Skip copy operation if file does not exist (i.e. target bug will have missing attachment)
# @todo maybe we should trigger an error instead in this case ?
if( file_exists( $t_source_file ) ) {
copy( $t_source_file, $t_new_diskfile_location );
chmod( $t_new_diskfile_location, config_get( 'attachments_file_permissions' ) );
}
}

$query = "INSERT INTO $t_mantis_bug_file_table
@@ -891,7 +903,7 @@ function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
" . db_param() . ",
" . db_param() . ",
" . db_param() . ");";
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'] ) );
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_file_path, $t_bug_file['filesize'], $t_bug_file['file_type'], $t_bug_file['date_added'], $t_bug_file['content'] ) );
}
}

9 changes: 7 additions & 2 deletions core/project_api.php
Original file line number Diff line number Diff line change
@@ -301,7 +301,10 @@ function project_create( $p_name, $p_description, $p_status, $p_view_state = VS_

project_ensure_name_unique( $p_name );

$p_file_path = validate_project_file_path( $p_file_path );
# Project does not exist yet, so we get global config
if( DATABASE !== config_get( 'file_upload_method', null, null, ALL_PROJECTS ) ) {
$p_file_path = validate_project_file_path( $p_file_path );
}

$t_project_table = db_get_table( 'mantis_project_table' );

@@ -395,7 +398,9 @@ function project_update( $p_project_id, $p_name, $p_description, $p_status, $p_v
project_ensure_name_unique( $p_name );
}

$p_file_path = validate_project_file_path( $p_file_path );
if( DATABASE !== config_get( 'file_upload_method', null, null, $p_project_id ) ) {
$p_file_path = validate_project_file_path( $p_file_path );
}

$t_project_table = db_get_table( 'mantis_project_table' );

85 changes: 51 additions & 34 deletions manage_proj_create_page.php
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@
?>

<br />
<!-- PROJECT PROPERTIES -->
<div align="center">
<form method="post" action="manage_proj_create.php">
<?php
@@ -47,6 +48,8 @@
<input type="hidden" name="parent_id" value="<?php echo $f_parent_id ?>">
<?php } ?>
<table class="width75" cellspacing="1">

<!-- Title -->
<tr>
<td class="form-title" colspan="2">
<?php
@@ -58,15 +61,19 @@
?>
</td>
</tr>
<tr class="row-1">

<!-- Name -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category" width="25%">
<span class="required">*</span><?php echo lang_get( 'project_name' )?>
<span class="required">*</span><?php echo lang_get( 'project_name' ) ?>
</td>
<td width="75%">
<input type="text" name="name" size="64" maxlength="128" />
<input type="text" name="name" size="60" maxlength="128" />
</td>
</tr>
<tr class="row-2">

<!-- Status -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'status' ) ?>
</td>
@@ -76,65 +83,75 @@
</select>
</td>
</tr>
<tr class="row-1">
<td class="category">
<?php echo lang_get( 'view_status' ) ?>
</td>
<td>
<select name="view_state">
<?php print_enum_string_option_list( 'view_state' ) ?>
</select>
</td>
</tr>
<tr class="row-2">

<!-- Category Inheritance -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'inherit_global' ) ?>
</td>
<td>
<input type="checkbox" name="inherit_global" checked="checked" />
</td>
</tr>

<?php if ( !is_null( $f_parent_id ) ) { ?>
<tr class="row-1">
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'inherit_parent' ) ?>
</td>
<td>
<input type="checkbox" name="inherit_parent" checked="checked" />
</td>
</tr>
<?php
}
<?php } ?>

<!-- View Status (public/private) -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'view_status' ) ?>
</td>
<td>
<select name="view_state">
<?php print_enum_string_option_list( 'view_state' ) ?>
</select>
</td>
</tr>

if ( config_get( 'allow_file_upload' ) ) {
$t_default_upload_path = '';
<!-- File upload path (if uploading is enabled and uploading to disk) -->
<?php
$g_project_override = ALL_PROJECTS;
if ( file_is_uploading_enabled() && DATABASE !== config_get( 'file_upload_method' ) ) {
?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'upload_file_path' ) ?>
</td>
<?php
$t_file_path = '';
# Don't reveal the absolute path to non-administrators for security reasons
if ( current_user_is_administrator() ) {
$t_default_upload_path = config_get( 'absolute_path_default_upload_folder' );
$t_file_path = config_get( 'absolute_path_default_upload_folder' );
}
?>
<tr class="row-2">
<td class="category">
<?php echo lang_get( 'upload_file_path' ) ?>
</td>
<td>
<input type="text" name="file_path" size="70" maxlength="250" value="<?php echo $t_default_upload_path ?>" />
</td>
</tr>
<?php
}
?>
<tr class="row-1">
<td>
<input type="text" name="file_path" size="60" maxlength="250" value="<?php echo $t_file_path ?>" />
</td>
</tr>
<?php } ?>

<!-- Description -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'description' ) ?>
</td>
<td>
<textarea name="description" cols="60" rows="5"></textarea>
<textarea name="description" cols="70" rows="5"></textarea>
</td>
</tr>

<?php event_signal( 'EVENT_MANAGE_PROJECT_CREATE_FORM' ) ?>

<!-- Submit Button -->
<tr>
<td class="center" colspan="2">
<input type="submit" class="button" value="<?php echo lang_get( 'add_project_button' ) ?>" />
26 changes: 14 additions & 12 deletions manage_proj_edit_page.php
Original file line number Diff line number Diff line change
@@ -65,10 +65,10 @@
<!-- Name -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category" width="25%">
<?php echo lang_get( 'project_name' ) ?>
<span class="required">*</span><?php echo lang_get( 'project_name' ) ?>
</td>
<td width="75%">
<input type="text" name="name" size="50" maxlength="128" value="<?php echo string_attribute( $row['name'] ) ?>" />
<input type="text" name="name" size="60" maxlength="128" value="<?php echo string_attribute( $row['name'] ) ?>" />
</td>
</tr>

@@ -117,20 +117,23 @@
</tr>

<!-- File upload path (if uploading is enabled and uploading to disk) -->
<?php if ( file_is_uploading_enabled() && DATABASE !== config_get( 'file_upload_method' ) ) { ?>
<?php
$g_project_override = $f_project_id;
if( file_is_uploading_enabled() && DATABASE !== config_get( 'file_upload_method' ) ) {
?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'upload_file_path' ) ?>
</td>
<?php
$t_file_path = $row['file_path'];
# Don't reveal the absolute path to non-administrators for security reasons
if ( is_blank( $t_file_path ) && current_user_is_administrator() ) {
$t_file_path = config_get( 'absolute_path_default_upload_folder' );
}
$t_file_path = $row['file_path'];
# Don't reveal the absolute path to non-administrators for security reasons
if ( is_blank( $t_file_path ) && current_user_is_administrator() ) {
$t_file_path = config_get( 'absolute_path_default_upload_folder' );
}
?>
<td>
<input type="text" name="file_path" size="50" maxlength="250" value="<?php echo string_attribute( $t_file_path ) ?>" />
<input type="text" name="file_path" size="60" maxlength="250" value="<?php echo string_attribute( $t_file_path ) ?>" />
</td>
</tr>
<?php } ?>
@@ -141,16 +144,15 @@
<?php echo lang_get( 'description' ) ?>
</td>
<td>
<textarea name="description" cols="60" rows="5"><?php echo string_textarea( $row['description'] ) ?></textarea>
<textarea name="description" cols="70" rows="5"><?php echo string_textarea( $row['description'] ) ?></textarea>
</td>
</tr>

<?php event_signal( 'EVENT_MANAGE_PROJECT_UPDATE_FORM', array( $f_project_id ) ); ?>

<!-- Submit Button -->
<tr>
<td>&#160;</td>
<td>
<td class="center" colspan="2">
<input type="submit" class="button" value="<?php echo lang_get( 'update_project_button' ) ?>" />
</td>
</tr>