diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 4a75a9b63b..d938135440 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -396,7 +396,10 @@ - {attachments.REAL_FILENAME}
{attachments.COMMENT}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE}{L_TOPIC}: {attachments.TOPIC_TITLE} + + {L_EXTENSION_GROUP}: {attachments.EXT_GROUP_NAME}{L_NO_EXT_GROUP}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE} + {attachments.REAL_FILENAME}
{attachments.COMMENT}
{attachments.L_DOWNLOAD_COUNT}
{L_TOPIC}: {attachments.TOPIC_TITLE} + {attachments.FILETIME}
{L_POST_BY_AUTHOR} {attachments.ATTACHMENT_POSTER} {attachments.FILESIZE} @@ -414,6 +417,7 @@ {L_DISPLAY_LOG}:  {S_LIMIT_DAYS} {L_SORT_BY}: {S_SORT_KEY} {S_SORT_DIR} +
-
-

 

{S_FORM_TOKEN} - + +
+ {L_RESYNC_STATS} +
+
+

{L_RESYNC_FILES_STATS_EXPLAIN}
+
+
+
+
+ diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 1c3c43c8e9..c62fefae46 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1097,8 +1097,8 @@ class acp_attachments // Sorting $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_ID'], 'u' => $user->lang['AUTHOR']); - $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.post_msg_id', 'u' => 'u.username'); + $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_TYPE'], 'u' => $user->lang['AUTHOR']); + $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.in_message', 'u' => 'u.username'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); @@ -1109,27 +1109,62 @@ class acp_attachments $attachments_per_page = (int) $config['topics_per_page']; - $num_files = (int) $config['num_files']; - $total_size = (int) $config['upload_dir_size']; + // Handle files stats resync + $action = request_var('action', ''); + $resync_files_stats = false; + if ($action && $action = 'stats') + { + if (!confirm_box(true)) + { + confirm_box(false, $user->lang['RESYNC_FILES_STATS_CONFIRM'], build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + ))); + } + else + { + $resync_files_stats = true; + add_log('admin', 'LOG_RESYNC_FILES_STATS'); + } + } - // Check if files statistics is accurate + // Check if files stats are accurate $sql = 'SELECT COUNT(attach_id) as num_files FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql, 600); $num_files_real = (int) $db->sql_fetchfield('num_files'); + if ($resync_files_stats === true) + { + set_config('num_files', $num_files_real, true); + } $db->sql_freeresult($result); $sql = 'SELECT SUM(filesize) as upload_dir_size FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql, 600); - $total_size_real = (int) $db->sql_fetchfield('upload_dir_size'); + $total_size_real = (float) $db->sql_fetchfield('upload_dir_size'); + if ($resync_files_stats === true) + { + set_config('upload_dir_size', $total_size_real, true); + } $db->sql_freeresult($result); + // Get current files stats + $num_files = (int) $config['num_files']; + $total_size = (float) $config['upload_dir_size']; + + // Issue warning message if files stats are inaccurate if (($num_files != $num_files_real) || ($total_size != $total_size_real)) { - $error[] = sprintf($user->lang['FILES_STAT_WRONG'], $num_files_real, get_formatted_filesize($total_size_real)); + $error[] = sprintf($user->lang['FILES_STATS_WRONG'], $num_files_real, get_formatted_filesize($total_size_real)); + + $template->assign_vars(array( + 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, + 'U_ACTION' => $this->u_action,) + ); } // Make sure $start is set to the last page if it exceeds the amount @@ -1207,7 +1242,7 @@ class acp_attachments $row = $attachments_list[$i]; $row['extension'] = strtolower(trim((string) $row['extension'])); - $comment = ($row['attach_comment']) ? str_replace(array("\n", "\r"), array('
', "\n"), $row['attach_comment']) : ''; + $comment = ($row['attach_comment'] && !$row['in_message']) ? str_replace(array("\n", "\r"), array('
', "\n"), $row['attach_comment']) : ''; $display_cat = $extensions[$row['extension']]['display_cat']; $l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNT' : 'VIEWED_COUNT'; $l_download_count = (!isset($row['download_count']) || (int) $row['download_count'] == 0) ? $user->lang[$l_downloaded_viewed . '_NONE'] : (((int) $row['download_count'] == 1) ? sprintf($user->lang[$l_downloaded_viewed], $row['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $row['download_count'])); @@ -1216,8 +1251,9 @@ class acp_attachments 'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']), 'FILESIZE' => get_formatted_filesize((int) $row['filesize']), 'FILETIME' => $user->format_date((int) $row['filetime']), - 'REAL_FILENAME' => utf8_wordwrap(utf8_basename((string) $row['real_filename']), 40, '
', true), + 'REAL_FILENAME' => (!$row['in_message']) ? utf8_wordwrap(utf8_basename((string) $row['real_filename']), 40, '
', true) : '', 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']), + 'EXT_GROUP_NAME' => (!empty($extensions[$row['extension']]['group_name'])) ? $user->lang['EXT_GROUP_' . $extensions[$row['extension']]['group_name']] : '', 'COMMENT' => $comment, 'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '', 'ATTACH_ID' => (int) $row['attach_id'], diff --git a/phpBB/includes/cache/service.php b/phpBB/includes/cache/service.php index 68026c8647..0c01953d55 100644 --- a/phpBB/includes/cache/service.php +++ b/phpBB/includes/cache/service.php @@ -194,6 +194,7 @@ class phpbb_cache_service 'max_filesize' => (int) $row['max_filesize'], 'allow_group' => $row['allow_group'], 'allow_in_pm' => $row['allow_in_pm'], + 'group_name' => $row['group_name'], ); $allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array(); diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index 9ae250a95a..eede2c5d50 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -62,6 +62,7 @@ $lang = array_merge($lang, array( 'ATTACH_MAX_PM_FILESIZE_EXPLAIN' => 'Maximum size of each file, with 0 being unlimited, attached to a private message.', 'ATTACH_ORPHAN_URL' => 'Orphan attachments', 'ATTACH_POST_ID' => 'Post ID', + 'ATTACH_POST_TYPE' => 'Post type', 'ATTACH_QUOTA' => 'Total attachment quota', 'ATTACH_QUOTA_EXPLAIN' => 'Maximum drive space available for attachments for the whole board, with 0 being unlimited.', 'ATTACH_TO_POST' => 'Attach file to post', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 11e8e05a56..2a8ed86175 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -239,7 +239,7 @@ $lang = array_merge($lang, array( 'EXPORT_STORE' => 'Store', 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', - 'FILES_STAT_WRONG' => 'Your files statistics is probably inaccurate and might need to be resynchronised. Actual values: number of attachments » %1$d, total size of attachments » %2$s.', + 'FILES_STATS_WRONG' => 'Your files statistics are probably inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.', 'GENERAL_OPTIONS' => 'General options', 'GENERAL_SETTINGS' => 'General settings', @@ -281,6 +281,8 @@ $lang = array_merge($lang, array( 'REMIND' => 'Remind', 'RESYNC' => 'Resynchronise', + 'RESYNC_FILES_STATS' => 'Resynchronise files statistics', + 'RESYNC_FILES_STATS_EXPLAIN' => 'Recalculates the total number and size of files attached to posts and private messages.', 'RETURN_TO' => 'Return to…', 'SELECT_ANONYMOUS' => 'Select anonymous user', @@ -367,6 +369,7 @@ $lang = array_merge($lang, array( 'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the board’s start date?', 'RESET_ONLINE' => 'Reset most users ever online', 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', + 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise files statistics?', 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', @@ -671,6 +674,7 @@ $lang = array_merge($lang, array( 'LOG_REFERER_INVALID' => 'Referer validation failed
»Referer was “%1$s”. The request was rejected and the session killed.', 'LOG_RESET_DATE' => 'Board start date reset', 'LOG_RESET_ONLINE' => 'Most users online reset', + 'LOG_RESYNC_FILES_STATS' => 'Files statistics resynchronised', 'LOG_RESYNC_POSTCOUNTS' => 'User post counts resynchronised', 'LOG_RESYNC_POST_MARKING' => 'Dotted topics resynchronised', 'LOG_RESYNC_STATS' => 'Post, topic and user statistics resynchronised',