diff options
| author | czaks <marcin@6irc.net> | 2014-04-29 21:35:50 +0200 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2014-04-29 21:35:50 +0200 |
| commit | bb5446a93d05185cc78cc4b61edc99d3035e295e (patch) | |
| tree | 9bd8e9cc87fa564f3e0cf4aa84c3c042690029a1 /inc | |
| parent | c1aaf78cbb126c51aa95afcac98f530512cb67f5 (diff) | |
| parent | bfc4df8276f1f3577e8d40f300ed0f3f02613cd0 (diff) | |
Merge remote-tracking branch 'origin/br-integration' into staging
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/config.php | 2 | ||||
| -rw-r--r-- | inc/mod/pages.php | 66 |
2 files changed, 68 insertions, 0 deletions
diff --git a/inc/config.php b/inc/config.php index 4ef55311..9a1dd706 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1402,6 +1402,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 89bc6e41..95a6d4db 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 = '<h4>Viewing last '.$limit.' posts</h4> + <p>View <a href="?/recent/25"> 25 </a>|<a href="?/recent/50"> 50 </a>|<a href="?/recent/100"> 100 </a></p> + <a href="javascript:void(0)" id="erase-local-data" style="float:right; clear:both">Erase local data</a></div>'; + 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('<p class="fileinfo">', + '<div class="post-wrapper" data-board="'.$post['board'].'"><a class="eita-link" id="eita-'.$post['board'].'-'.$post['id'].'" href="?/'.$post['board'].'/res/'.$post['id'].'.html#'.$post['id'].'">/'.$post['board'].'/'.$post['id'].'</a><br><p class="fileinfo">', + $string); + } else { + $po = new Post($post, '?/', $mod); + $string = $po->build(true); + $replacement = str_replace('<div class="post reply"', + '<div class="post-wrapper" data-board="'.$post['board'].'"><a class="eita-link" id="eita-'.$post['board'].'-'.$post['id'].'" href="?/'.$post['board'].'/res/'.$post['thread'].'.html#'.$post['id'].'">/'.$post['board'].'/'.$post['id'].'</a><br><div class="post reply"', + $string); + } + $body .= $replacement . '</div>'; + } + + echo Element('page.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; |
