From fb2b66e2dd67ceefc94d8e64eedd9300f64d695f Mon Sep 17 00:00:00 2001 From: sinuca <55vitaminado@gmail.com> Date: Mon, 17 Mar 2014 19:11:16 -0300 Subject: Recent posts functionality Conflicts: inc/config.php inc/mod/pages.php mod.php --- inc/mod/pages.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'inc/mod/pages.php') 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 = '

Viewing last '.$limit.' posts

+

View 25 | 50 | 100

+ Erase local data'; + foreach ($posts as $post) { + openBoard($post['board']); + if (!$post['thread']) { + // Still need to fix this: + $po = new Thread($post, '?/', $mod, false); + $string = $po->build(true); + $replacement = str_replace('

', + '

/'.$post['board'].'/'.$post['id'].'

', + $string); + } else { + $po = new Post($post, '?/', $mod); + $string = $po->build(true); + $replacement = str_replace('

/'.$post['board'].'/'.$post['id'].'
'; + } + + echo Element('modpage.html', array( + 'config' => $config, + 'mod' => $mod, + 'hide_dashboard_link' => true, + 'title' => _('Recent posts'), + 'subtitle' => '', + 'nojavascript' => false, + 'is_recent_posts' => true, + 'body' => $body + ) + ); + +} function mod_config($board_config = false) { global $config, $mod, $board; -- cgit v1.3 From 9d9d514919625ac66178198045b2a997d282b5c7 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 25 Mar 2014 11:57:36 +0100 Subject: we no have any modpages.html --- inc/mod/pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/mod/pages.php') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index b9f3b045..9294e801 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2266,7 +2266,7 @@ function mod_recent_posts($lim) { $body .= $replacement . '
'; } - echo Element('modpage.html', array( + echo Element('page.html', array( 'config' => $config, 'mod' => $mod, 'hide_dashboard_link' => true, -- cgit v1.3