Skip to content

Commit

Permalink
Improve labels for Move Attachments system utility
Browse files Browse the repository at this point in the history
system_utils.php:
- changed description to clearly state that the action can move files
  both to database and to disk
- changed button label to remove "to disk"

move_attachments_page.php
- add tooltips for Storage column header and cells in "To Disk" and
  "To Database" columns
- remove obsolete <th> width attribute, improve table layout
- fix static analysis warnings

Fixes #4993
  • Loading branch information
dregad committed Apr 23, 2023
1 parent 4d08ef6 commit 3fdf46b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 26 deletions.
53 changes: 32 additions & 21 deletions admin/move_attachments_page.php
Expand Up @@ -23,7 +23,7 @@
* @link http://www.mantisbt.org
*/

require_once( dirname( dirname( __FILE__ ) ) . '/core.php' );
require_once( dirname( __FILE__, 2 ) . '/core.php' );

access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );

Expand Down Expand Up @@ -120,13 +120,16 @@ function get_attachment_stats( $p_file_type, $p_in_db ) {
<thead>
<tr>
<th>Project name</th>
<th width="28%">File Path</th>
<th width="5%">Disk</th>
<th width="5%">Database</th>
<th width="5%">Attachments</th>
<th width="5%">Storage</th>
<th width="7%">To Disk</th>
<th width="7%">To Database</th>
<th>File Path</th>
<th class="center">Disk</th>
<th class="center">Database</th>
<th class="center">Attachments</th>
<th class="center"
title="As defined by file_upload_method config for the project">
Storage
</th>
<th class="center">To Disk</th>
<th class="center">To Database</th>
</tr>
</thead>

Expand All @@ -147,9 +150,11 @@ function get_attachment_stats( $p_file_type, $p_in_db ) {
$t_upload_method = config_get( 'file_upload_method', null, ALL_USERS, $t_id );
if( $t_upload_method == DISK ) {
$t_method = 'Disk';
$t_target = 'disk';
} else {
# Must be DATABASE
$t_method = 'Database';
$t_target = 'db';
}

$t_file_path = $t_project['file_path'];
Expand All @@ -165,20 +170,26 @@ function get_attachment_stats( $p_file_type, $p_in_db ) {
echo '<td class="center">' . ( $t_db_count + $t_disk_count ) . '</td>';
echo '<td class="center">' . $t_method . '</td>';

$t_cell_checkbox = sprintf( '<td class="center">'
. '<input type="checkbox" name="to_move[]" value="%s:%d" title="Tick to move '
. $t_type . '" /></td>',
$t_target,
$t_id
);
$t_cell_noaction = '<td class="center" title="No ' . $t_type . ' need moving"">-</td>';

if( $t_upload_method == DISK ) {
if ( !is_blank( $t_file_path ) && $t_db_count > 0 ) {
echo '<td class="center"><input type="checkbox" name="to_move[]" value="disk:' . $t_id . '" /></td>';
} else {
echo '<td class="center">-</td>';
}
echo '<td class="center">-</td>';
# To Database column
echo !is_blank( $t_file_path ) && $t_db_count > 0 ? $t_cell_checkbox : $t_cell_noaction;

# To Disk column
echo $t_cell_noaction;
} else {
echo '<td class="center">-</td>';
if ( $t_disk_count > 0 ) {
echo '<td class="center"><input type="checkbox" name="to_move[]" value="db:' . $t_id . '" /></td>';
} else {
echo '<td class="center">-</td>';
}
# To Database column
echo $t_cell_noaction;

# To Disk column
echo $t_disk_count ? $t_cell_checkbox : $t_cell_noaction;
}
echo "</tr>\n";
}
Expand All @@ -189,7 +200,7 @@ function get_attachment_stats( $p_file_type, $p_in_db ) {
</table>
<div class="widget-toolbox padding-8 clearfix">
<input name="type" type="hidden" value="<?php echo string_attribute( $f_file_type); ?>" />
<input type="submit" class="btn btn-primary btn-white btn-round" value="Move Attachments" />
<input type="submit" class="btn btn-primary btn-white btn-round" value="Move <?php echo $t_type ?>" />
</div>
</div>
</form>
Expand Down
16 changes: 11 additions & 5 deletions admin/system_utils.php
Expand Up @@ -59,19 +59,25 @@
</thead>
<tbody>
<tr>
<td>Move attachments stored in database schema to disk files.</td>
<td>Move attachments stored in database schema to disk files and vice versa</td>
<td class="center">
<?php html_button( 'move_attachments_page.php', 'Move Attachments to Disk', array( 'type' => 'bug' ) );?>
<?php html_button( 'move_attachments_page.php',
'Move Attachments',
array( 'type' => 'bug' ) );
?>
</td>
</tr>
<tr>
<td>Move project files stored in database schema to disk.</td>
<td>Move project files stored in database schema to disk and vice versa</td>
<td class="center">
<?php html_button( 'move_attachments_page.php', 'Move Project Files to Disk', array( 'type' => 'project' ) );?>
<?php html_button( 'move_attachments_page.php',
'Move Project Files',
array( 'type' => 'project' ) );
?>
</td>
</tr>
<tr>
<td>Show database statistics.</td>
<td>Show database statistics</td>
<td class="center">
<?php html_button( 'db_stats.php', 'Display', array() );?>
</td>
Expand Down

0 comments on commit 3fdf46b

Please sign in to comment.