diff --git a/inc/config.php b/inc/config.php index 1bf55fb7..b2f62f5e 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1376,6 +1376,8 @@ $config['mod']['view_ban_appeals'] = MOD; // Accept and deny ban appeals $config['mod']['ban_appeals'] = MOD; + // View the recent posts page + $config['mod']['recent'] = MOD; // Config editor permissions $config['mod']['config'] = array(); diff --git a/inc/mod/pages.php b/inc/mod/pages.php index a247e35c..b9f3b045 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2213,6 +2213,72 @@ function mod_report_dismiss($id, $all = false) { header('Location: ?/reports', true, $config['redirect_http']); } +function mod_recent_posts($lim) { + global $config, $mod, $pdo; + + if (!hasPermission($config['mod']['recent'])) + error($config['error']['noaccess']); + + $limit = (is_numeric($lim))? $lim : 25; + + $mod_boards = array(); + $boards = listBoards(); + + //if not all boards + if ($mod['boards'][0]!='*') { + foreach ($boards as $board) { + if (in_array($board['uri'], $mod['boards'])) + $mod_boards[] = $board; + } + } else { + $mod_boards = $boards; + } + + // Manually build an SQL query + $query = 'SELECT * FROM ('; + foreach ($mod_boards as $board) { + $query .= sprintf('SELECT *, %s AS `board` FROM ``posts_%s`` UNION ALL ', $pdo->quote($board['uri']), $board['uri']); + } + // Remove the last "UNION ALL" seperator and complete the query + $query = preg_replace('/UNION ALL $/', ') AS `all_posts` ORDER BY `time` DESC LIMIT ' . $limit, $query); + $query = query($query) or error(db_error()); + $posts = $query->fetchAll(PDO::FETCH_ASSOC); + + $body = '
', + '
', + $string); + } else { + $po = new Post($post, '?/', $mod); + $string = $po->build(true); + $replacement = str_replace('
({% trans 'There are no active posts.' %})
+{% else %} + +{% endif %} \ No newline at end of file