summaryrefslogtreecommitdiff
path: root/inc/display.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/display.php')
-rw-r--r--inc/display.php138
1 files changed, 10 insertions, 128 deletions
diff --git a/inc/display.php b/inc/display.php
index f02df433..9397b4a9 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -96,7 +96,7 @@ function error($message, $priority = true, $debug_stuff = false) {
// Return the bad request header, necessary for AJAX posts
// czaks: is it really so? the ajax errors only work when this is commented out
- // better yet use it when ajax is disabled
+ // better yet use it when ajax is disabled
if (!isset ($_POST['json_response'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
}
@@ -352,6 +352,9 @@ class Post {
foreach ($post as $key => $value) {
$this->{$key} = $value;
}
+
+ if (isset($this->files))
+ $this->files = json_decode($this->files);
$this->subject = utf8tohtml($this->subject);
$this->name = utf8tohtml($this->name);
@@ -382,64 +385,11 @@ class Post {
return $this->root . $board['dir'] . $config['dir']['res'] . sprintf(($page ? $page : $config['file_page']), $this->thread) . '#' . $pre . $this->id;
}
- public function postControls() {
- global $board, $config;
-
- $built = '';
- if ($this->mod) {
- // Mod controls (on posts)
-
- // Delete
- if (hasPermission($config['mod']['delete'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_delete'], 'Delete', 'Are you sure you want to delete this?', $board['dir'] . 'delete/' . $this->id);
-
- // Delete all posts by IP
- if (hasPermission($config['mod']['deletebyip'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], 'Delete all posts by IP', 'Are you sure you want to delete all posts by this IP address?', $board['dir'] . 'deletebyip/' . $this->id);
-
- // Delete all posts by IP (global)
- if (hasPermission($config['mod']['deletebyip_global'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], 'Delete all posts by IP across all boards', 'Are you sure you want to delete all posts by this IP address, across all boards?', $board['dir'] . 'deletebyip/' . $this->id . '/global');
-
- // Ban
- if (hasPermission($config['mod']['ban'], $board['uri'], $this->mod))
- $built .= ' <a title="'._('Ban').'" href="?/' . $board['dir'] . 'ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
-
- // Ban & Delete
- if (hasPermission($config['mod']['bandelete'], $board['uri'], $this->mod))
- $built .= ' <a title="'._('Ban & Delete').'" href="?/' . $board['dir'] . 'ban&amp;delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
-
- // Delete file (keep post)
- if (!empty($this->file) && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id);
-
- // Spoiler file (keep post)
- if (!empty($this->file) && $this->file != "deleted" && $this->file != null && $this->thumb != 'spoiler' && hasPermission($config['mod']['spoilerimage'], $board['uri'], $this->mod) && $config['spoiler_images'])
- $built .= ' ' . secure_link_confirm($config['mod']['link_spoilerimage'], _('Spoiler File'), _('Are you sure you want to spoiler this file?'), $board['uri'] . '/spoiler/' . $this->id);
-
- // Move post
- if (hasPermission($config['mod']['move'], $board['uri'], $this->mod) && $config['move_replies'])
- $built .= ' <a title="'._('Move reply to another board').'" href="?/' . $board['uri'] . '/move_reply/' . $this->id . '">' . $config['mod']['link_move'] . '</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>';
-
-
- if (!empty($built))
- $built = '<span class="controls">' . $built . '</span>';
- }
- return $built;
- }
-
- public function ratio() {
- return fraction($this->filewidth, $this->fileheight, ':');
- }
public function build($index=false) {
global $board, $config;
- return Element('post_reply.html', array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index));
+ return Element('post_reply.html', array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index, 'mod' => $this->mod));
}
};
@@ -453,6 +403,9 @@ class Thread {
$this->{$key} = $value;
}
+ if (isset($this->files))
+ $this->files = json_decode($this->files);
+
$this->subject = utf8tohtml($this->subject);
$this->name = utf8tohtml($this->name);
$this->mod = $mod;
@@ -491,79 +444,8 @@ class Thread {
$this->posts[] = $post;
}
public function postCount() {
- return count($this->posts) + $this->omitted;
+ return count($this->posts) + $this->omitted;
}
- public function postControls() {
- global $board, $config;
-
- $built = '';
- if ($this->mod) {
- // Mod controls (on posts)
- // Delete
- if (hasPermission($config['mod']['delete'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_delete'], _('Delete'), _('Are you sure you want to delete this?'), $board['dir'] . 'delete/' . $this->id);
-
- // Delete all posts by IP
- if (hasPermission($config['mod']['deletebyip'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], _('Delete all posts by IP'), _('Are you sure you want to delete all posts by this IP address?'), $board['dir'] . 'deletebyip/' . $this->id);
-
- // Delete all posts by IP (global)
- if (hasPermission($config['mod']['deletebyip_global'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], _('Delete all posts by IP across all boards'), _('Are you sure you want to delete all posts by this IP address, across all boards?'), $board['dir'] . 'deletebyip/' . $this->id . '/global');
-
- // Ban
- if (hasPermission($config['mod']['ban'], $board['uri'], $this->mod))
- $built .= ' <a title="'._('Ban').'" href="?/' . $board['dir'] . 'ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
-
- // Ban & Delete
- if (hasPermission($config['mod']['bandelete'], $board['uri'], $this->mod))
- $built .= ' <a title="'._('Ban & Delete').'" href="?/' . $board['dir'] . 'ban&amp;delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
-
- // Delete file (keep post)
- if (!empty($this->file) && $this->file != 'deleted' && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod))
- $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id);
-
- // Spoiler file (keep post)
- if (!empty($this->file) && $this->file != "deleted" && $this->file != null && $this->thumb != 'spoiler' && hasPermission($config['mod']['spoilerimage'], $board['uri'], $this->mod) && $config['spoiler_images'])
- $built .= ' ' . secure_link_confirm($config['mod']['link_spoilerimage'], _('Spoiler File'), _('Are you sure you want to spoiler this file?'), $board['uri'] . '/spoiler/' . $this->id);
-
- // Sticky
- if (hasPermission($config['mod']['sticky'], $board['uri'], $this->mod))
- if ($this->sticky)
- $built .= ' <a title="'._('Make thread not sticky').'" href="?/' . secure_link($board['dir'] . 'unsticky/' . $this->id) . '">' . $config['mod']['link_desticky'] . '</a>';
- else
- $built .= ' <a title="'._('Make thread sticky').'" href="?/' . secure_link($board['dir'] . 'sticky/' . $this->id) . '">' . $config['mod']['link_sticky'] . '</a>';
-
- if (hasPermission($config['mod']['bumplock'], $board['uri'], $this->mod))
- if ($this->sage)
- $built .= ' <a title="'._('Allow thread to be bumped').'" href="?/' . secure_link($board['dir'] . 'bumpunlock/' . $this->id) . '">' . $config['mod']['link_bumpunlock'] . '</a>';
- else
- $built .= ' <a title="'._('Prevent thread from being bumped').'" href="?/' . secure_link($board['dir'] . 'bumplock/' . $this->id) . '">' . $config['mod']['link_bumplock'] . '</a>';
-
- // Lock
- if (hasPermission($config['mod']['lock'], $board['uri'], $this->mod))
- if ($this->locked)
- $built .= ' <a title="'._('Unlock thread').'" href="?/' . secure_link($board['dir'] . 'unlock/' . $this->id) . '">' . $config['mod']['link_unlock'] . '</a>';
- else
- $built .= ' <a title="'._('Lock thread').'" href="?/' . secure_link($board['dir'] . 'lock/' . $this->id) . '">' . $config['mod']['link_lock'] . '</a>';
-
- 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>';
-
- // 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>';
-
- if (!empty($built))
- $built = '<span class="controls op">' . $built . '</span>';
- }
- return $built;
- }
-
- public function ratio() {
- return fraction($this->filewidth, $this->fileheight, ':');
- }
-
public function build($index=false, $isnoko50=false) {
global $board, $config, $debug;
@@ -571,7 +453,7 @@ class Thread {
event('show-thread', $this);
- $built = Element('post_thread.html', array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index, 'hasnoko50' => $hasnoko50, 'isnoko50' => $isnoko50));
+ $built = Element('post_thread.html', array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index, 'hasnoko50' => $hasnoko50, 'isnoko50' => $isnoko50, 'mod' => $this->mod));
return $built;
}