Adds limit to overboard catalog

This commit is contained in:
nonmakina 2021-01-10 22:18:32 -06:00
parent 5eea6c4ac7
commit 2d1a712a20
2 changed files with 14 additions and 4 deletions

View File

@ -97,6 +97,13 @@
'default' => 'overboard',
'comment' => 'Fill in the location of the overboard directory. Default is \'overboard\' which corresponds to ./overboard'
);
$theme['config'][] = Array(
'title' => 'Max posts in catalog overboard',
'name' => 'overboard_limit',
'type' => 'text',
'default' => '350',
'comment' => 'The maximum number of thread that will appear in the overboard catalog'
);
// Unique function name for building everything
$theme['build_function'] = 'catalog_build';

View File

@ -357,12 +357,15 @@
} else {
$sql = '';
foreach ($boards as $board) {
$sql .= $this->buildThreadsQuery($board);
$sql .= '('. $this->buildThreadsQuery($board) . ')';
$sql .= " UNION ALL ";
}
$sql = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC', $sql);
$result = query($sql) or error(db_error());
$threads = $result->fetchAll(PDO::FETCH_ASSOC);
$sql = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC LIMIT :limit', $sql);
$query = prepare($sql);
$query->bindValue(':limit', $settings['overboard_limit'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
$threads = $query->fetchAll(PDO::FETCH_ASSOC);
// Save for posterity
$this->threadsCache[$board_name] = $threads;
}