Skip to content

Commit

Permalink
starting to integrate thread archive
Browse files Browse the repository at this point in the history
  • Loading branch information
twiforce committed Jun 2, 2014
1 parent f4b343c commit 5816ca5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
3 changes: 3 additions & 0 deletions inc/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@
$config['mod']['link_bumpunlock'] = '[-Sage]';
$config['mod']['link_editpost'] = '[Edit]';
$config['mod']['link_move'] = '[Move]';
$config['mod']['link_arch'] = '[Archive]';

// Moderator capcodes.
$config['capcode'] = ' <span class="capcode">## %s</span>';
Expand Down Expand Up @@ -1334,6 +1335,8 @@
$config['mod']['editpost'] = ADMIN;
// "Move" a thread to another board (EXPERIMENTAL; has some known bugs)
$config['mod']['move'] = DISABLED;
// Move generated thread page to /$board/arch
$config['mod']['arch'] = DISABLED;
// Bypass "field_disable_*" (forced anonymity, etc.)
$config['mod']['bypass_field_disable'] = MOD;
// Post bypass unoriginal content check on robot-enabled boards
Expand Down
5 changes: 4 additions & 1 deletion inc/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,10 @@ public function postControls() {

if (hasPermission($config['mod']['move'], $board['uri'], $this->mod))
$built .= ' <a title="'._('Move thread to another board').'" href="?/' . $board['dir'] . 'move/' . $this->id . '">' . $config['mod']['link_move'] . '</a>';


if (hasPermission($config['mod']['arch'], $board['uri'], $this->mod))
$built .= ' <a title="'._('Move thread to archive').'" href="?/' . $board['dir'] . 'arch/' . $this->id . '">' . $config['mod']['link_arch'] . '</a>';

// Edit post
if (hasPermission($config['mod']['editpost'], $board['uri'], $this->mod))
$built .= ' <a title="'._('Edit post').'" href="?/' . $board['dir'] . 'edit' . ($config['mod']['raw_html_default'] ? '_raw' : '') . '/' . $this->id . '">' . $config['mod']['link_editpost'] . '</a>';
Expand Down
45 changes: 45 additions & 0 deletions inc/mod/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,51 @@ function mod_move($originBoard, $postID) {
mod_page(_('Move thread'), 'mod/move.html', array('post' => $postID, 'board' => $originBoard, 'boards' => $boards, 'token' => $security_token));
}

function mod_archive($board, $post) {
global $config, $mod;

if (!openBoard($board))
error($config['error']['noboard']);

if (!hasPermission($config['mod']['arch'], $board))
error($config['error']['noaccess']);

// Move filepages to arch folder
$threadPath = sprintf($config['board_path'], $board) . 'res/' . $post . ".html";
$threadJSON = sprintf($config['board_path'], $board) . 'res/' . $post . ".json";
$thread50page = sprintf($config['board_path'], $board) . 'res/' . $post . "+50.html";
$threadArchPath = sprintf($config['board_path'], $board) . 'arch/' . $post . ".html";
if (!file_exists(sprintf($config['board_path'], $board) . 'arch') and !is_dir(sprintf($config['board_path'], $board) . 'arch')) {
mkdir (sprintf($config['board_path'], $board) . 'arch', 0777, true);
}
rename($threadPath, $threadArchPath);
if (file_exists($threadJSON)) {
file_unlink($threadJSON);
}
if (file_exists($thread50page)) {
file_unlink($thread50page);
}

// Delete thread
$query = prepare(sprintf('DELETE FROM ``posts_%s`` WHERE `thread` = :post', $board));
$query->bindValue(':post', $post, PDO::PARAM_INT);
$query->execute() or error(db_error($query));

// Delete posts from this thread
$query = prepare(sprintf('DELETE FROM ``posts_%s`` WHERE `id` = :post', $board));
$query->bindValue(':post', $post, PDO::PARAM_INT);
$query->execute() or error(db_error($query));

// Record the action
modLog("Thread #{$post} moved to archive");
// Rebuild board
buildIndex();
// Rebuild themes
rebuildThemes('post-delete', $board);
// Redirect
header('Location: ?/' . sprintf($config['board_path'], $board), true, $config['redirect_http']);
}

function mod_ban_post($board, $delete, $post, $token = false) {
global $config, $mod;

Expand Down
1 change: 1 addition & 0 deletions mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function strip_array($var) {
'/(\%b)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address
'/(\%b)/(un)?lock/(\d+)' => 'secure lock', // lock thread
'/(\%b)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread
'/(\%b)/arch/(\d+)' => 'archive', // move to archive
'/(\%b)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread

'/themes' => 'themes_list', // manage themes
Expand Down

0 comments on commit 5816ca5

Please sign in to comment.