Index: mantisbt/admin/schema.php =================================================================== --- mantisbt/admin/schema.php (revision 5358) +++ mantisbt/admin/schema.php (working copy) @@ -409,3 +409,5 @@ $upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_custom_field_table' ), " filter_by L NOTNULL DEFAULT \" '1' \"" ) ); + +$upgrade[] = Array( 'AddColumnSQL', Array(db_get_table('mantis_project_file_table'), "visible_in_child L NOTNULL DEFAULT '1' AFTER description") ); \ No newline at end of file Index: mantisbt/core/file_api.php =================================================================== --- mantisbt/core/file_api.php (revision 5358) +++ mantisbt/core/file_api.php (working copy) @@ -526,7 +526,7 @@ } # -------------------- - function file_add( $p_bug_id, $p_tmp_file, $p_file_name, $p_file_type='', $p_table = 'bug', $p_file_error = 0, $p_title = '', $p_desc = '' ) { + function file_add( $p_bug_id, $p_tmp_file, $p_file_name, $p_file_type='', $p_table = 'bug', $p_file_error = 0, $p_title = '', $p_desc = '', $p_visible_in_child = false ) { switch ( (int) $p_file_error ) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: @@ -558,6 +558,7 @@ if ( 'bug' == $p_table ) { $t_project_id = bug_get_field( $p_bug_id, 'project_id' ); $t_bug_id = bug_format_id( $p_bug_id ); + $p_visible_in_child = false; } else { $t_project_id = helper_get_current_project(); $t_bug_id = 0; @@ -569,6 +570,7 @@ $c_file_type = db_prepare_string( $p_file_type ); $c_title = db_prepare_string( $p_title ); $c_desc = db_prepare_string( $p_desc ); + $c_visible_in_child = db_prepare_bool( $p_visible_in_child ); if( $t_project_id == ALL_PROJECTS ) { $t_file_path = config_get( 'absolute_path_default_upload_folder' ); @@ -631,10 +633,17 @@ $t_file_table = db_get_table( 'mantis_' . $p_table . '_file_table' ); $c_id = ( 'bug' == $p_table ) ? $c_bug_id : $c_project_id; + if( 'bug' == $p_table ) { $query = "INSERT INTO $t_file_table (" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content) VALUES ($c_id, '$c_title', '$c_desc', '$c_disk_file_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', '" . db_now() ."', $c_content)"; + } else { + $query = "INSERT INTO $t_file_table + (" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, visible_in_child) + VALUES + ($c_id, '$c_title', '$c_desc', '$c_disk_file_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', '" . db_now() ."', $c_content, $c_visible_in_child)"; + } db_query( $query ); if ( 'bug' == $p_table ) { Index: mantisbt/lang/strings_english.txt =================================================================== --- mantisbt/lang/strings_english.txt (revision 5358) +++ mantisbt/lang/strings_english.txt (working copy) @@ -1025,6 +1025,8 @@ # proj_doc_add_page.php $s_upload_file_title = 'Upload File'; $s_title = 'Title'; +$s_visible_in_child_project = 'Visible in child projects'; +$s_visibility = 'Visibility'; # proj_doc_delete.php $s_project_file_deleted_msg = 'Project file deleted'; Index: mantisbt/proj_doc_add.php =================================================================== --- mantisbt/proj_doc_add.php (revision 5358) +++ mantisbt/proj_doc_add.php (working copy) @@ -39,6 +39,7 @@ $f_title = gpc_get_string( 'title' ); $f_description = gpc_get_string( 'description' ); $f_file = gpc_get_file( 'file' ); + $f_visible_in_child = gpc_get_bool( 'visible_in_child', false ); if ( is_blank( $f_title ) ) { error_parameters( lang_get( 'title' ) ); @@ -46,7 +47,7 @@ } $f_file_error = ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0; - file_add( 0, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'project', $f_file_error, $f_title, $f_description ); + file_add( 0, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'project', $f_file_error, $f_title, $f_description, $f_visible_in_child ); $t_redirect_url = 'proj_doc_page.php'; Index: mantisbt/proj_doc_add_page.php =================================================================== --- mantisbt/proj_doc_add_page.php (revision 5358) +++ mantisbt/proj_doc_add_page.php (working copy) @@ -71,6 +71,14 @@ + + + + + + + + * (' . lang_get( 'max_file_size' ) . ': ' . number_format( $t_max_file_size/1000 ) . 'k)'?> Index: mantisbt/proj_doc_edit_page.php =================================================================== --- mantisbt/proj_doc_edit_page.php (revision 5358) +++ mantisbt/proj_doc_edit_page.php (working copy) @@ -89,6 +89,14 @@ + + + + > + + + + @@ -100,7 +108,7 @@ ?> - + (' . lang_get( 'max_file_size' ) . ': ' . number_format( $t_max_file_size/1000 ) . 'k)'?> Index: mantisbt/proj_doc_page.php =================================================================== --- mantisbt/proj_doc_page.php (revision 5358) +++ mantisbt/proj_doc_page.php (working copy) @@ -50,8 +50,9 @@ # Select all the projects that the user has access to $t_projects = user_get_accessible_projects( $t_user_id ); } else { - # Select the specific project - $t_projects = array( $f_project_id ); + # Select the specific project and it's parents + project_hierarchy_cache(); + $t_projects = project_hierarchy_inheritance( $f_project_id ); } $t_projects[] = ALL_PROJECTS; # add "ALL_PROJECTS to the list of projects to fetch @@ -67,7 +68,7 @@ $t_access_clause = ">= $t_reqd_access "; } - $query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added + $query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added, pft.visible_in_child FROM $t_project_file_table pft LEFT JOIN $t_project_table pt ON pft.project_id = pt.id LEFT JOIN $t_project_user_list_table pult @@ -104,6 +105,10 @@ $v_description = string_display_links( $v_description ); $v_date_added = date( config_get( 'normal_date_format' ), db_unixtimestamp( $v_date_added ) ); + if( $f_project_id != ALL_PROJECTS && $v_project_id != ALL_PROJECTS && + $v_project_id != $f_project_id && !$v_visible_in_child ) + continue; + ?> > Index: mantisbt/proj_doc_update.php =================================================================== --- mantisbt/proj_doc_update.php (revision 5358) +++ mantisbt/proj_doc_update.php (working copy) @@ -40,6 +40,7 @@ $f_title = gpc_get_string( 'title' ); $f_description = gpc_get_string( 'description' ); $f_file = gpc_get_file( 'file' ); + $f_visible_in_child = gpc_get_bool( 'visible_in_child' ); $t_project_id = file_get_field( $f_file_id, 'project_id', 'project' ); @@ -52,6 +53,7 @@ $c_file_id = db_prepare_int( $f_file_id ); $c_title = db_prepare_string( $f_title ); $c_description = db_prepare_string( $f_description ); + $c_visible_in_child = db_prepare_bool( $f_visible_in_child ); $t_project_file_table = db_get_table( 'mantis_project_file_table' ); @@ -134,14 +136,16 @@ } $query = "UPDATE $t_project_file_table SET title=" . db_param(0) . ", description=" . db_param(1) . ", date_added=" . db_param(2) . ", - filename=" . db_param(3) . ", filesize=" . db_param(4) . ", file_type=" .db_param(5) . ", content=" .db_param(6) . " - WHERE id=" . db_param(7); - $result = db_query_bound( $query, Array( $c_title, $c_description, db_now(), $c_file_name, $c_file_size, $c_file_type, $c_content, $c_file_id ) ); + filename=" . db_param(3) . ", filesize=" . db_param(4) . ", file_type=" .db_param(5) . ", content=" .db_param(6) . ", + visible_in_child=" . db_param(7) . " + WHERE id=" . db_param(8); + $result = db_query_bound( $query, Array( $c_title, $c_description, db_now(), $c_file_name, $c_file_size, $c_file_type, $c_content, $c_visible_in_child, $c_file_id ) ); } else { $query = "UPDATE $t_project_file_table - SET title=" . db_param(0) . ", description=" . db_param(1) . " - WHERE id=" . db_param(2); - $result = db_query_bound( $query, Array( $c_title, $c_description, $c_file_id ) ); + SET title=" . db_param(0) . ", description=" . db_param(1) . ", + visible_in_child=" . db_param(2) . " + WHERE id=" . db_param(3); + $result = db_query_bound( $query, Array( $c_title, $c_description, $c_visible_in_child, $c_file_id ) ); } if ( !$result ) {