I found a issue #0011965 and patch for it. But since it for v1.2.1 i edit a litle bit for v1.2.5 and apply. Only one bug: counter updates every time page reload. Please, help me fix this issue. Tnx!
Code: Select all
1. Add field 'downloaded' (int(10), default:0) into database table 'mantis_bug_file_table'.
2. In file 'bug_api.php' find function 'bug_get_attachments', add field 'downloaded' to query:
line 1398: "$query = "SELECT id, title, diskfile, filename, filesize, file_type, date_added, user_id, downloaded"
3. In file 'file_api.php',find function 'file_get_visible_attachments', add the lines:
$t_downloaded = $t_row['downloaded'];
$t_attachment['downloaded'] = $t_downloaded;
just before (line 285): "if( $t_attachment['can_download'] ) {"
4. In file 'file_download.php', add the following lines:
# Update download counter
$query2 = "UPDATE $t_bug_file_table SET downloaded=downloaded+1 WHERE id=" . $v_id;
$result2 = db_query_bound( $query2 );
just after (line 94): "if ( !file_can_download_bug_attachments( $v_bug_id, (int)$v_user_id ) ) { access_denied(); }"
5. Last change in file 'print-api.php', find function 'print_bug_attachments_list', add the line:
$t_downloaded = $t_attachment['downloaded'] ;
just after (line 1665): "$t_date_added = date( config_get( 'normal_date_format' ), $t_attachment['date_added'] );"
6.Finally change the actual line that prints the attachment (line 1690) with:
echo $t_href_end . ' ' . $t_href_start . $t_file_display_name . $t_href_end . $t_href_clicket . ' (' . $t_filesize . ' ' . lang_get( 'bytes' ) . ') ' . '<span class="italic">' . $t_date_added . ' Downloaded: '. $t_downloaded . ' time(s)</span>';