. /** * This upgrade moves attachments from the database to the disk * * @package MantisBT * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org * @copyright Copyright (C) 2002 - 2014 MantisBT Team - mantisbt-dev@lists.sourceforge.net * @link http://www.mantisbt.org */ /** * MantisBT Core API's */ require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' ); access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); # Page header, menu html_page_top( 'MantisBT Administration - Moving Attachments' ); echo '

'; print_bracket_link( helper_mantis_url( 'admin/system_utils.php' ), 'Back to System Utilities' ); echo '

'; # File type should be 'bug' (default) or 'project' $f_file_type = gpc_get( 'type', 'bug' ); $t_bug_table = db_get_table( 'mantis_bug_table' ); $t_project_table = db_get_table( 'mantis_project_table' ); switch( $f_file_type ) { case 'project': $t_type = 'Project Files'; $t_file_table = db_get_table( 'mantis_project_file_table' ); $t_query = "SELECT p.id, p.name, COUNT(f.id) disk FROM $t_file_table f LEFT JOIN $t_project_table p ON p.id = f.project_id WHERE content <> '' GROUP BY p.id, p.name ORDER BY p.name"; break; case 'bug': default: $t_type = 'Attachments'; $t_file_table = db_get_table( 'mantis_bug_file_table' ); $t_query = "SELECT p.id, p.name, COUNT(f.id) disk FROM $t_file_table f JOIN $t_bug_table b ON b.id = f.bug_id JOIN $t_project_table p ON p.id = b.project_id WHERE content <> '' GROUP BY p.id, p.name ORDER BY p.name"; break; } # Move to disk: projects having non-empty attachments in the DB $t_result = db_query_bound( $t_query ); # Build list, excluding projects having upload method other than DISK $t_projects = array(); while( $t_row = db_fetch_array( $t_result ) ) { $t_project_id = (int) $t_row['id']; $t_upload_method = config_get( 'file_upload_method', null, ALL_USERS, $t_project_id ); if( $t_upload_method == DISK ) { $t_projects[$t_project_id] = $t_row; } } if( count( $t_projects ) == 0 ) { # Nothing to do echo '

No attachments need to be moved.

'; } else { # Display name for All Projects if( isset( $t_projects[ALL_PROJECTS] ) ) { $t_projects[ALL_PROJECTS]['name'] = 'All Projects'; } # Display table of projects for user selection ?>
$t_project ) { echo ''; printf( '', $t_project['name'], $t_project['disk'], $t_id ); echo "\n"; } if( ON == config_get( 'use_javascript' ) ) { ?>
Project name Attachments To Disk
%s%s' . '
Select All