Permalink
Browse files

Allow moving attachments for multiple projects

- replaced radio button with checkbox
- minor layout adjustments
- refactor logic in action page to make sure multiple project selection works

Fixes #21927
  • Loading branch information...
1 parent 0464b12 commit 900469d87bae5c59b531fb0e97b58ef303e11a68 @jllano jllano committed with vboctor Nov 29, 2016
Showing with 34 additions and 25 deletions.
  1. +26 −17 admin/move_attachments.php
  2. +8 −8 admin/move_attachments_page.php
@@ -257,20 +257,24 @@ function move_attachments_to_disk( $p_type, array $p_projects ) {
return $t_moved;
}
-$t_array = explode( ':', $f_project_to_move, 2 );
-if( isset( $t_array[1] ) ) {
- $f_project_id = $t_array[1];
-
- if( !is_numeric( $f_project_id ) || (int)$f_project_id == 0 ) {
- $t_moved = array();
- } else {
- switch( $t_array[0] ) {
- case 'disk':
- $t_moved = move_attachments_to_disk( $f_file_type, array( $f_project_id ) );
- break;
- case 'db':
- $t_moved = move_attachments_to_db( $f_file_type, array( $f_project_id ) );
- break;
+$t_moved = array();
+
+if ( null != $f_project_to_move ) {
+ foreach ( $f_project_to_move as $t_project_to_move) {
+
+ $t_array = explode( ':', $t_project_to_move );
+
+ if( isset( $t_array[1] ) ) {
+ $f_project_id = $t_array[1];
+
+ switch( $t_array[0] ) {
+ case 'disk':
+ $t_moved[] = move_attachments_to_disk( $f_file_type, array( $f_project_id ) );
+ break;
+ case 'db':
+ $t_moved[] = move_attachments_to_db( $f_file_type, array( $f_project_id ) );
+ break;
+ }
}
}
}
@@ -291,9 +295,13 @@ function move_attachments_to_disk( $p_type, array $p_projects ) {
# Display results
if( empty( $t_moved ) ) {
- echo '<p class="lead">Nothing to do.</p>'. "\n";
+ echo '<div class="alert alert-danger">';
+ echo '<p class="lead"><strong>Opps!</strong> Please select the project you want to move the attachment.</p>';
+ echo '</div>';
} else {
foreach( $t_moved as $t_row ) {
+ $t_row = $t_row[0];
+
echo '<div class="widget-box widget-color-blue2">';
echo '<div class="widget-header widget-header-small">';
echo '<h4 class="widget-title lighter">';
@@ -315,8 +323,8 @@ function move_attachments_to_disk( $p_type, array $p_projects ) {
echo '<table class="table table-bordered table-condensed">';
echo '<thead>';
echo '<tr>',
- $f_file_type == 'bug' ? '<td>Bug ID</td>' : '',
- '<td>File ID</td><th>Filename</td><td>Status</td>',
+ $f_file_type == 'bug' ? '<td width="5%">Bug ID</td>' : '',
+ '<td width="3%">File ID</td><th width="15%">Filename</td><td width="25%">Status</td>',
'</tr>';
echo '</thead>';
echo '<tbody>';
@@ -343,6 +351,7 @@ function move_attachments_to_disk( $p_type, array $p_projects ) {
echo '</div>';
echo '</div>';
echo '</div>';
+ echo "<br/>";
}
}
echo "<br/>";
@@ -119,11 +119,11 @@ function get_attachment_stats( $p_file_type, $p_in_db ) {
<table class="table table-bordered table-condensed">
<tr>
<th>Project name</th>
- <th width="18%">File Path</th>
- <th width="18%">Disk</th>
- <th width="18%">Database</th>
- <th width="18%">Attachments</th>
- <th width="18%">Storage</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>
</tr>
@@ -156,23 +156,23 @@ function get_attachment_stats( $p_file_type, $p_in_db ) {
echo '<tr>';
echo '<td>' . $t_project['name'] . '</td>';
- echo '<td class="center">' . $t_file_path . '</td>';
+ echo '<td class="left">' . $t_file_path . '</td>';
echo '<td class="center">' . $t_disk_count . '</td>';
echo '<td class="center">' . $t_db_count . '</td>';
echo '<td class="center">' . ( $t_db_count + $t_disk_count ) . '</td>';
echo '<td class="center">' . $t_method . '</td>';
if( $t_upload_method == DISK ) {
if ( !is_blank( $t_file_path ) && $t_db_count > 0 ) {
- echo '<td class="center"><input type="radio" name="to_move" value="disk:' . $t_id . '" /></td>';
+ 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>';
} else {
echo '<td class="center">-</td>';
if ( $t_disk_count > 0 ) {
- echo '<td class="center"><input type="radio" name="to_move" value="db:' . $t_id . '" /></td>';
+ echo '<td class="center"><input type="checkbox" name="to_move[]" value="db:' . $t_id . '" /></td>';
} else {
echo '<td class="center">-</td>';
}

0 comments on commit 900469d

Please sign in to comment.