aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2017-11-02 21:14:09 +0100
committerMarc Alexander <admin@m-a-styles.de>2017-11-02 21:14:09 +0100
commit3b5f5113ac6b562f9e1107ef70a64e3a181aebfd (patch)
treefc1937a8e90854d189036407f4d7f38619883aab /phpBB/includes/acp
parentc3cc6bcbac7917433f95570c4e07038b07dd1173 (diff)
parentcc361144f9d53890f3a846df2e1ccc8e7544f849 (diff)
downloadforums-3b5f5113ac6b562f9e1107ef70a64e3a181aebfd.tar
forums-3b5f5113ac6b562f9e1107ef70a64e3a181aebfd.tar.gz
forums-3b5f5113ac6b562f9e1107ef70a64e3a181aebfd.tar.bz2
forums-3b5f5113ac6b562f9e1107ef70a64e3a181aebfd.tar.xz
forums-3b5f5113ac6b562f9e1107ef70a64e3a181aebfd.zip
Merge pull request #5008 from rubencm/ticket/15041
[ticket/15041] Add pagination to orphaned attachments
Diffstat (limited to 'phpBB/includes/acp')
-rw-r--r--phpBB/includes/acp/acp_attachments.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 3cfe5de293..2480f1f025 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -922,6 +922,9 @@ class acp_attachments
case 'orphan':
+ /* @var $pagination \phpbb\pagination */
+ $pagination = $this->phpbb_container->get('pagination');
+
if ($submit)
{
$delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array();
@@ -1064,13 +1067,29 @@ class acp_attachments
'S_ORPHAN' => true)
);
+ $attachments_per_page = (int) $config['topics_per_page'];
+
+ // Get total number or orphans older than 3 hours
+ $sql = 'SELECT COUNT(attach_id) as num_files, SUM(filesize) as total_size
+ FROM ' . ATTACHMENTS_TABLE . '
+ WHERE is_orphan = 1
+ AND filetime < ' . (time() - 3*60*60);
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $num_files = (int) $row['num_files'];
+ $total_size = (int) $row['total_size'];
+ $this->db->sql_freeresult($result);
+
+ $start = $request->variable('start', 0);
+ $start = $pagination->validate_start($start, $attachments_per_page, $num_files);
+
// Just get the files with is_orphan set and older than 3 hours
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE is_orphan = 1
AND filetime < ' . (time() - 3*60*60) . '
ORDER BY filetime DESC';
- $result = $db->sql_query($sql);
+ $result = $db->sql_query_limit($sql, $attachments_per_page, $start);
while ($row = $db->sql_fetchrow($result))
{
@@ -1086,6 +1105,20 @@ class acp_attachments
}
$db->sql_freeresult($result);
+ $pagination->generate_template_pagination(
+ $this->u_action,
+ 'pagination',
+ 'start',
+ $num_files,
+ $attachments_per_page,
+ $start
+ );
+
+ $template->assign_vars(array(
+ 'TOTAL_FILES' => $num_files,
+ 'TOTAL_SIZE' => get_formatted_filesize($total_size),
+ ));
+
break;
case 'manage':