|
@@ -7,7 +7,7 @@ class Topic extends Page
|
|
use UsersTrait;
|
|
use UsersTrait;
|
|
use OnlineTrait;
|
|
use OnlineTrait;
|
|
use CrumbTrait;
|
|
use CrumbTrait;
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Имя шаблона
|
|
* Имя шаблона
|
|
* @var string
|
|
* @var string
|
|
@@ -27,7 +27,7 @@ class Topic extends Page
|
|
* @var bool
|
|
* @var bool
|
|
*/
|
|
*/
|
|
protected $onlineType = true;
|
|
protected $onlineType = true;
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Тип возврата данных при onlineType === true
|
|
* Тип возврата данных при onlineType === true
|
|
* Если true, то из online должны вернутся только пользователи находящиеся на этой же странице
|
|
* Если true, то из online должны вернутся только пользователи находящиеся на этой же странице
|
|
@@ -41,7 +41,7 @@ class Topic extends Page
|
|
* @param array $args
|
|
* @param array $args
|
|
* @return Page
|
|
* @return Page
|
|
*/
|
|
*/
|
|
- public function goToNew(array $args)
|
|
|
|
|
|
+ public function viewNew(array $args)
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
@@ -51,9 +51,9 @@ class Topic extends Page
|
|
* @param array $args
|
|
* @param array $args
|
|
* @return Page
|
|
* @return Page
|
|
*/
|
|
*/
|
|
- public function goToUnread(array $args)
|
|
|
|
|
|
+ public function viewUnread(array $args)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -61,7 +61,7 @@ class Topic extends Page
|
|
* @param array $args
|
|
* @param array $args
|
|
* @return Page
|
|
* @return Page
|
|
*/
|
|
*/
|
|
- public function goToLast(array $args)
|
|
|
|
|
|
+ public function viewLast(array $args)
|
|
{
|
|
{
|
|
$vars = [
|
|
$vars = [
|
|
':tid' => $args['id'],
|
|
':tid' => $args['id'],
|
|
@@ -86,20 +86,23 @@ class Topic extends Page
|
|
{
|
|
{
|
|
$vars = [
|
|
$vars = [
|
|
':pid' => $args['id'],
|
|
':pid' => $args['id'],
|
|
|
|
+ ':uid' => $this->c->user->id,
|
|
];
|
|
];
|
|
|
|
|
|
if ($this->c->user->isGuest) {
|
|
if ($this->c->user->isGuest) {
|
|
- $sql = 'SELECT t.*, f.moderators, 0 AS is_subscribed
|
|
|
|
- FROM ::topics AS t
|
|
|
|
- INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
|
|
|
|
+ $sql = 'SELECT t.*, f.moderators, 0 AS is_subscribed, 0 AS mf_mark_all_read, 0 AS mt_last_visit, 0 AS mt_last_read
|
|
|
|
+ FROM ::topics AS t
|
|
|
|
+ INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
INNER JOIN ::posts AS p ON t.id=p.topic_id
|
|
INNER JOIN ::posts AS p ON t.id=p.topic_id
|
|
WHERE p.id=?i:pid AND t.moved_to IS NULL';
|
|
WHERE p.id=?i:pid AND t.moved_to IS NULL';
|
|
} else {
|
|
} else {
|
|
- $sql = 'SELECT t.*, f.moderators, s.user_id AS is_subscribed
|
|
|
|
- FROM ::topics AS t
|
|
|
|
- INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
|
|
|
|
+ $sql = 'SELECT t.*, f.moderators, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
|
|
|
|
+ FROM ::topics AS t
|
|
|
|
+ INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
INNER JOIN ::posts AS p ON t.id=p.topic_id
|
|
INNER JOIN ::posts AS p ON t.id=p.topic_id
|
|
- LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
|
|
|
|
|
|
+ LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
|
|
|
|
+ LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND f.id=mof.fid)
|
|
|
|
+ LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND t.id=mot.tid)
|
|
WHERE p.id=?i:pid AND t.moved_to IS NULL';
|
|
WHERE p.id=?i:pid AND t.moved_to IS NULL';
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,18 +118,21 @@ class Topic extends Page
|
|
{
|
|
{
|
|
$vars = [
|
|
$vars = [
|
|
':tid' => $args['id'],
|
|
':tid' => $args['id'],
|
|
|
|
+ ':uid' => $this->c->user->id,
|
|
];
|
|
];
|
|
|
|
|
|
if ($this->c->user->isGuest) {
|
|
if ($this->c->user->isGuest) {
|
|
- $sql = 'SELECT t.*, f.moderators, 0 AS is_subscribed
|
|
|
|
- FROM ::topics AS t
|
|
|
|
- INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
|
|
|
|
+ $sql = 'SELECT t.*, f.moderators, 0 AS is_subscribed, 0 AS mf_mark_all_read, 0 AS mt_last_visit, 0 AS mt_last_read
|
|
|
|
+ FROM ::topics AS t
|
|
|
|
+ INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
WHERE t.id=?i:tid AND t.moved_to IS NULL';
|
|
WHERE t.id=?i:tid AND t.moved_to IS NULL';
|
|
} else {
|
|
} else {
|
|
- $sql = 'SELECT t.*, f.moderators, s.user_id AS is_subscribed
|
|
|
|
- FROM ::topics AS t
|
|
|
|
- INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
|
|
- LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
|
|
|
|
|
|
+ $sql = 'SELECT t.*, f.moderators, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
|
|
|
|
+ FROM ::topics AS t
|
|
|
|
+ INNER JOIN ::forums AS f ON f.id=t.forum_id
|
|
|
|
+ LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
|
|
|
|
+ LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND f.id=mof.fid)
|
|
|
|
+ LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND t.id=mot.tid)
|
|
WHERE t.id=?i:tid AND t.moved_to IS NULL';
|
|
WHERE t.id=?i:tid AND t.moved_to IS NULL';
|
|
}
|
|
}
|
|
|
|
|
|
@@ -149,19 +155,19 @@ class Topic extends Page
|
|
$vars[':uid'] = $user->id;
|
|
$vars[':uid'] = $user->id;
|
|
|
|
|
|
$topic = $this->c->DB->query($sql, $vars)->fetch();
|
|
$topic = $this->c->DB->query($sql, $vars)->fetch();
|
|
-
|
|
|
|
|
|
+
|
|
// тема отсутствует или недоступна
|
|
// тема отсутствует или недоступна
|
|
if (empty($topic)) {
|
|
if (empty($topic)) {
|
|
return $this->c->Message->message('Bad request');
|
|
return $this->c->Message->message('Bad request');
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
list($fTree, $fDesc, $fAsc) = $this->c->forums;
|
|
list($fTree, $fDesc, $fAsc) = $this->c->forums;
|
|
-
|
|
|
|
|
|
+
|
|
// раздел отсутствует в доступных
|
|
// раздел отсутствует в доступных
|
|
if (empty($fDesc[$topic['forum_id']])) {
|
|
if (empty($fDesc[$topic['forum_id']])) {
|
|
return $this->c->Message->message('Bad request');
|
|
return $this->c->Message->message('Bad request');
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (null === $page) {
|
|
if (null === $page) {
|
|
$vars[':tid'] = $topic['id'];
|
|
$vars[':tid'] = $topic['id'];
|
|
$sql = 'SELECT COUNT(id) FROM ::posts WHERE topic_id=?i:tid AND id<?i:pid';
|
|
$sql = 'SELECT COUNT(id) FROM ::posts WHERE topic_id=?i:tid AND id<?i:pid';
|
|
@@ -185,28 +191,32 @@ class Topic extends Page
|
|
':offset' => $offset,
|
|
':offset' => $offset,
|
|
':rows' => $user->dispPosts,
|
|
':rows' => $user->dispPosts,
|
|
];
|
|
];
|
|
- $sql = 'SELECT id
|
|
|
|
- FROM ::posts
|
|
|
|
- WHERE topic_id=?i:tid
|
|
|
|
|
|
+ $sql = 'SELECT id
|
|
|
|
+ FROM ::posts
|
|
|
|
+ WHERE topic_id=?i:tid
|
|
ORDER BY id LIMIT ?i:offset, ?i:rows';
|
|
ORDER BY id LIMIT ?i:offset, ?i:rows';
|
|
|
|
|
|
$ids = $this->c->DB->query($sql, $vars)->fetchAll(\PDO::FETCH_COLUMN);
|
|
$ids = $this->c->DB->query($sql, $vars)->fetchAll(\PDO::FETCH_COLUMN);
|
|
|
|
|
|
// нарушена синхронизация количества сообщений в темах
|
|
// нарушена синхронизация количества сообщений в темах
|
|
if (empty($ids)) {
|
|
if (empty($ids)) {
|
|
- return $this->goToLast($topic['id']);
|
|
|
|
|
|
+ return $this->viewLast($topic['id']);
|
|
}
|
|
}
|
|
|
|
|
|
$moders = empty($topic['moderators']) ? [] : array_flip(unserialize($topic['moderators']));
|
|
$moders = empty($topic['moderators']) ? [] : array_flip(unserialize($topic['moderators']));
|
|
$parent = isset($fDesc[$topic['forum_id']][0]) ? $fDesc[$topic['forum_id']][0] : 0;
|
|
$parent = isset($fDesc[$topic['forum_id']][0]) ? $fDesc[$topic['forum_id']][0] : 0;
|
|
$perm = $fTree[$parent][$topic['forum_id']];
|
|
$perm = $fTree[$parent][$topic['forum_id']];
|
|
|
|
|
|
|
|
+ if($user->isBot) {
|
|
|
|
+ $perm['post_replies'] = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
$newOn = null;
|
|
$newOn = null;
|
|
if ($user->isAdmin) {
|
|
if ($user->isAdmin) {
|
|
$newOn = true;
|
|
$newOn = true;
|
|
} elseif ($topic['closed'] == '1') {
|
|
} elseif ($topic['closed'] == '1') {
|
|
$newOn = false;
|
|
$newOn = false;
|
|
- } elseif ($perm['post_replies'] === 1
|
|
|
|
|
|
+ } elseif ($perm['post_replies'] === 1
|
|
|| (null === $perm['post_replies'] && $user->gPostReplies == '1')
|
|
|| (null === $perm['post_replies'] && $user->gPostReplies == '1')
|
|
|| ($user->isAdmMod && isset($moders[$user->id]))
|
|
|| ($user->isAdmMod && isset($moders[$user->id]))
|
|
) {
|
|
) {
|
|
@@ -222,23 +232,23 @@ class Topic extends Page
|
|
$vars = [
|
|
$vars = [
|
|
':ids' => $ids,
|
|
':ids' => $ids,
|
|
];
|
|
];
|
|
- $sql = 'SELECT id, message, poster, posted
|
|
|
|
- FROM ::warnings
|
|
|
|
|
|
+ $sql = 'SELECT id, message, poster, posted
|
|
|
|
+ FROM ::warnings
|
|
WHERE id IN (?ai:ids)';
|
|
WHERE id IN (?ai:ids)';
|
|
|
|
|
|
$warnings = $this->c->DB->query($sql, $vars)->fetchAll(\PDO::FETCH_GROUP);
|
|
$warnings = $this->c->DB->query($sql, $vars)->fetchAll(\PDO::FETCH_GROUP);
|
|
-
|
|
|
|
|
|
+
|
|
$vars = [
|
|
$vars = [
|
|
':ids' => $ids,
|
|
':ids' => $ids,
|
|
];
|
|
];
|
|
- $sql = 'SELECT u.warning_all, u.gender, u.email, u.title, u.url, u.location, u.signature,
|
|
|
|
- u.email_setting, u.num_posts, u.registered, u.admin_note, u.messages_enable,
|
|
|
|
- p.id, p.poster as username, p.poster_id, p.poster_ip, p.poster_email, p.message,
|
|
|
|
- p.hide_smilies, p.posted, p.edited, p.edited_by, p.edit_post, p.user_agent,
|
|
|
|
- g.g_id, g.g_user_title, g.g_promote_next_group, g.g_pm
|
|
|
|
- FROM ::posts AS p
|
|
|
|
- INNER JOIN ::users AS u ON u.id=p.poster_id
|
|
|
|
- INNER JOIN ::groups AS g ON g.g_id=u.group_id
|
|
|
|
|
|
+ $sql = 'SELECT u.warning_all, u.gender, u.email, u.title, u.url, u.location, u.signature,
|
|
|
|
+ u.email_setting, u.num_posts, u.registered, u.admin_note, u.messages_enable,
|
|
|
|
+ p.id, p.poster as username, p.poster_id, p.poster_ip, p.poster_email, p.message,
|
|
|
|
+ p.hide_smilies, p.posted, p.edited, p.edited_by, p.edit_post, p.user_agent,
|
|
|
|
+ g.g_id, g.g_user_title, g.g_promote_next_group, g.g_pm
|
|
|
|
+ FROM ::posts AS p
|
|
|
|
+ INNER JOIN ::users AS u ON u.id=p.poster_id
|
|
|
|
+ INNER JOIN ::groups AS g ON g.g_id=u.group_id
|
|
WHERE p.id IN (?ai:ids) ORDER BY p.id';
|
|
WHERE p.id IN (?ai:ids) ORDER BY p.id';
|
|
|
|
|
|
$stmt = $this->c->DB->query($sql, $vars);
|
|
$stmt = $this->c->DB->query($sql, $vars);
|
|
@@ -268,6 +278,7 @@ class Topic extends Page
|
|
$posts = [];
|
|
$posts = [];
|
|
$signs = [];
|
|
$signs = [];
|
|
$posters = [];
|
|
$posters = [];
|
|
|
|
+ $timeMax = 0;
|
|
while ($cur = $stmt->fetch()) {
|
|
while ($cur = $stmt->fetch()) {
|
|
// данные по автору сообшения
|
|
// данные по автору сообшения
|
|
if (isset($posters[$cur['poster_id']])) {
|
|
if (isset($posters[$cur['poster_id']])) {
|
|
@@ -285,7 +296,7 @@ class Topic extends Page
|
|
'poster_posts' => null,
|
|
'poster_posts' => null,
|
|
'poster_gender' => '',
|
|
'poster_gender' => '',
|
|
'poster_online' => '',
|
|
'poster_online' => '',
|
|
-
|
|
|
|
|
|
+
|
|
];
|
|
];
|
|
if ($cur['poster_id'] > 1) {
|
|
if ($cur['poster_id'] > 1) {
|
|
if ($user->gViewUsers == '1') {
|
|
if ($user->gViewUsers == '1') {
|
|
@@ -296,12 +307,12 @@ class Topic extends Page
|
|
}
|
|
}
|
|
if ($this->config['o_show_user_info'] == '1') {
|
|
if ($this->config['o_show_user_info'] == '1') {
|
|
$post['poster_info_add'] = true;
|
|
$post['poster_info_add'] = true;
|
|
-
|
|
|
|
|
|
+
|
|
$post['poster_registered'] = $this->time($cur['registered'], true);
|
|
$post['poster_registered'] = $this->time($cur['registered'], true);
|
|
-
|
|
|
|
|
|
+
|
|
$post['poster_posts'] = $this->number($cur['num_posts']);
|
|
$post['poster_posts'] = $this->number($cur['num_posts']);
|
|
$post['poster_num_posts'] = $cur['num_posts'];
|
|
$post['poster_num_posts'] = $cur['num_posts'];
|
|
-
|
|
|
|
|
|
+
|
|
if ($cur['location'] != '') {
|
|
if ($cur['location'] != '') {
|
|
$post['poster_location'] = $this->censor($cur['location']);
|
|
$post['poster_location'] = $this->censor($cur['location']);
|
|
}
|
|
}
|
|
@@ -313,9 +324,9 @@ class Topic extends Page
|
|
|
|
|
|
$posters[$cur['poster_id']] = $post;
|
|
$posters[$cur['poster_id']] = $post;
|
|
|
|
|
|
- if ($this->config['o_signatures'] == '1'
|
|
|
|
- && $cur['signature'] != ''
|
|
|
|
- && $user->showSig == '1'
|
|
|
|
|
|
+ if ($this->config['o_signatures'] == '1'
|
|
|
|
+ && $cur['signature'] != ''
|
|
|
|
+ && $user->showSig == '1'
|
|
&& ! isset($signs[$cur['poster_id']])
|
|
&& ! isset($signs[$cur['poster_id']])
|
|
) {
|
|
) {
|
|
$signs[$cur['poster_id']] = $cur['signature'];
|
|
$signs[$cur['poster_id']] = $cur['signature'];
|
|
@@ -329,6 +340,8 @@ class Topic extends Page
|
|
$post['posted'] = $this->time($cur['posted']);
|
|
$post['posted'] = $this->time($cur['posted']);
|
|
$post['posted_utc'] = gmdate('Y-m-d\TH:i:s\Z', $cur['posted']);
|
|
$post['posted_utc'] = gmdate('Y-m-d\TH:i:s\Z', $cur['posted']);
|
|
|
|
|
|
|
|
+ $timeMax = max($timeMax, $cur['posted']);
|
|
|
|
+
|
|
$parser->parse($this->censor($cur['message']));
|
|
$parser->parse($this->censor($cur['message']));
|
|
if ($this->config['o_smilies'] == '1' && $user->showSmilies == '1' && $cur['hide_smilies'] == '0') {
|
|
if ($this->config['o_smilies'] == '1' && $user->showSmilies == '1' && $cur['hide_smilies'] == '0') {
|
|
$parser->detectSmilies();
|
|
$parser->detectSmilies();
|
|
@@ -345,31 +358,32 @@ class Topic extends Page
|
|
|
|
|
|
// данные по элементам управления
|
|
// данные по элементам управления
|
|
$controls = [];
|
|
$controls = [];
|
|
|
|
+ $vars = ['id' => $cur['id']];
|
|
if (! $user->isAdmin && ! $user->isGuest) {
|
|
if (! $user->isAdmin && ! $user->isGuest) {
|
|
- $controls['report'] = ['#', 'Report'];
|
|
|
|
|
|
+ $controls['report'] = [$this->c->Router->link('ReportPost', $vars), 'Report'];
|
|
}
|
|
}
|
|
- if ($user->isAdmin
|
|
|
|
|
|
+ if ($user->isAdmin
|
|
|| ($user->isAdmMod && isset($moders[$user->id]) && ! in_array($cur['poster_id'], $this->c->admins))
|
|
|| ($user->isAdmMod && isset($moders[$user->id]) && ! in_array($cur['poster_id'], $this->c->admins))
|
|
) {
|
|
) {
|
|
- $controls['delete'] = ['#', 'Delete'];
|
|
|
|
- $controls['edit'] = ['#', 'Edit'];
|
|
|
|
- } elseif ($topic['closed'] != '1'
|
|
|
|
|
|
+ $controls['delete'] = [$this->c->Router->link('DeletePost', $vars), 'Delete'];
|
|
|
|
+ $controls['edit'] = [$this->c->Router->link('EditPost', $vars), 'Edit'];
|
|
|
|
+ } elseif ($topic['closed'] != '1'
|
|
&& $cur['poster_id'] == $user->id
|
|
&& $cur['poster_id'] == $user->id
|
|
&& ($user->gDeleditInterval == '0' || $cur['edit_post'] == '1' || time() - $cur['posted'] < $user->gDeleditInterval)
|
|
&& ($user->gDeleditInterval == '0' || $cur['edit_post'] == '1' || time() - $cur['posted'] < $user->gDeleditInterval)
|
|
) {
|
|
) {
|
|
if (($cur['id'] == $topic['first_post_id'] && $user->gDeleteTopics == '1') || ($cur['id'] != $topic['first_post_id'] && $user->gDeletePosts == '1')) {
|
|
if (($cur['id'] == $topic['first_post_id'] && $user->gDeleteTopics == '1') || ($cur['id'] != $topic['first_post_id'] && $user->gDeletePosts == '1')) {
|
|
- $controls['delete'] = ['#', 'Delete'];
|
|
|
|
|
|
+ $controls['delete'] = [$this->c->Router->link('DeletePost', $vars), 'Delete'];
|
|
}
|
|
}
|
|
if ($user->gEditPosts == '1') {
|
|
if ($user->gEditPosts == '1') {
|
|
- $controls['edit'] = ['#', 'Edit'];
|
|
|
|
|
|
+ $controls['edit'] = [$this->c->Router->link('EditPost', $vars), 'Edit'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($newOn) {
|
|
if ($newOn) {
|
|
- $controls['quote'] = ['#', 'Reply'];
|
|
|
|
|
|
+ $controls['quote'] = [$this->c->Router->link('NewReply', ['id' => $topic['id'], 'quote' => $cur['id']]), 'Reply'];
|
|
}
|
|
}
|
|
|
|
|
|
$post['controls'] = $controls;
|
|
$post['controls'] = $controls;
|
|
-
|
|
|
|
|
|
+
|
|
$posts[] = $post;
|
|
$posts[] = $post;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -392,9 +406,76 @@ class Topic extends Page
|
|
}
|
|
}
|
|
|
|
|
|
$topic['subject'] = $this->censor($topic['subject']);
|
|
$topic['subject'] = $this->censor($topic['subject']);
|
|
-
|
|
|
|
|
|
+
|
|
$this->onlinePos = 'topic-' . $topic['id'];
|
|
$this->onlinePos = 'topic-' . $topic['id'];
|
|
|
|
|
|
|
|
+ // данные для формы быстрого ответа
|
|
|
|
+ $form = null;
|
|
|
|
+ if ($newOn && $this->config['o_quickpost'] == '1') {
|
|
|
|
+ $form = [
|
|
|
|
+ 'action' => $this->c->Router->link('NewReply', ['id' => $topic['id']]),
|
|
|
|
+ 'hidden' => [
|
|
|
|
+ 'token' => $this->c->Csrf->create('NewReply', ['id' => $topic['id']]),
|
|
|
|
+ ],
|
|
|
|
+ 'sets' => [],
|
|
|
|
+ 'btns' => [
|
|
|
|
+ 'submit' => ['submit', __('Submit'), 's'],
|
|
|
|
+ 'preview' => ['submit', __('Preview'), 'p'],
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $fieldset = [];
|
|
|
|
+ if ($user->isGuest) {
|
|
|
|
+ $fieldset['username'] = [
|
|
|
|
+ 'dl' => 't1',
|
|
|
|
+ 'type' => 'text',
|
|
|
|
+ 'maxlength' => 25,
|
|
|
|
+ 'title' => __('Username'),
|
|
|
|
+ 'required' => true,
|
|
|
|
+ 'pattern' => '^.{2,25}$',
|
|
|
|
+ ];
|
|
|
|
+ $fieldset['email'] = [
|
|
|
|
+ 'dl' => 't2',
|
|
|
|
+ 'type' => 'text',
|
|
|
|
+ 'maxlength' => 80,
|
|
|
|
+ 'title' => __('Email'),
|
|
|
|
+ 'required' => $this->config['p_force_guest_email'] == '1',
|
|
|
|
+ 'pattern' => '.+@.+',
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $fieldset['message'] = [
|
|
|
|
+ 'type' => 'textarea',
|
|
|
|
+ 'title' => __('Message'),
|
|
|
|
+ 'required' => true,
|
|
|
|
+ 'bb' => [
|
|
|
|
+ ['link', __('BBCode'), __($this->config['p_message_bbcode'] == '1' ? 'on' : 'off')],
|
|
|
|
+ ['link', __('url tag'), __($this->config['p_message_bbcode'] == '1' && $user->gPostLinks == '1' ? 'on' : 'off')],
|
|
|
|
+ ['link', __('img tag'), __($this->config['p_message_bbcode'] == '1' && $this->config['p_message_img_tag'] == '1' ? 'on' : 'off')],
|
|
|
|
+ ['link', __('Smilies'), __($this->config['o_smilies'] == '1' ? 'on' : 'off')],
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+ $form['sets'][] = [
|
|
|
|
+ 'fields' => $fieldset,
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $fieldset = [];
|
|
|
|
+ if ($user->isAdmin || ($user->isAdmMod && isset($moders[$user->id]))) {
|
|
|
|
+ $fieldset['merge'] = [
|
|
|
|
+ 'type' => 'checkbox',
|
|
|
|
+ 'label' => __('Merge posts'),
|
|
|
|
+ 'value' => '1',
|
|
|
|
+ 'checked' => true,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ if ($fieldset) {
|
|
|
|
+ $form['sets'][] = [
|
|
|
|
+ 'legend' => __('Options'),
|
|
|
|
+ 'fields' => $fieldset,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
$this->data = [
|
|
$this->data = [
|
|
'topic' => $topic,
|
|
'topic' => $topic,
|
|
'posts' => $posts,
|
|
'posts' => $posts,
|
|
@@ -404,11 +485,12 @@ class Topic extends Page
|
|
['Topic', ['id' => $topic['id'], 'name' => $topic['subject']]],
|
|
['Topic', ['id' => $topic['id'], 'name' => $topic['subject']]],
|
|
[$fDesc, $topic['forum_id']]
|
|
[$fDesc, $topic['forum_id']]
|
|
),
|
|
),
|
|
- 'newPost' => $newOn ? $this->c->Router->link('NewPost', ['id' => $topic['id']]) : $newOn,
|
|
|
|
|
|
+ 'NewReply' => $newOn ? $this->c->Router->link('NewReply', ['id' => $topic['id']]) : $newOn,
|
|
'stickFP' => $stickFP,
|
|
'stickFP' => $stickFP,
|
|
'pages' => $this->c->Func->paginate($pages, $page, 'Topic', ['id' => $topic['id'], 'name' => $topic['subject']]),
|
|
'pages' => $this->c->Func->paginate($pages, $page, 'Topic', ['id' => $topic['id'], 'name' => $topic['subject']]),
|
|
'online' => $this->getUsersOnlineInfo(),
|
|
'online' => $this->getUsersOnlineInfo(),
|
|
'stats' => null,
|
|
'stats' => null,
|
|
|
|
+ 'form' => $form,
|
|
];
|
|
];
|
|
|
|
|
|
$this->canonical = $this->c->Router->link('Topic', ['id' => $topic['id'], 'name' => $topic['subject'], 'page' => $page]);
|
|
$this->canonical = $this->c->Router->link('Topic', ['id' => $topic['id'], 'name' => $topic['subject'], 'page' => $page]);
|
|
@@ -422,6 +504,41 @@ class Topic extends Page
|
|
$this->c->DB->query($sql, $vars);
|
|
$this->c->DB->query($sql, $vars);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (! $user->isGuest) {
|
|
|
|
+ $vars = [
|
|
|
|
+ ':uid' => $user->id,
|
|
|
|
+ ':tid' => $topic['id'],
|
|
|
|
+ ':read' => $topic['mt_last_read'],
|
|
|
|
+ ':visit' => $topic['mt_last_visit'],
|
|
|
|
+ ];
|
|
|
|
+ $flag = false;
|
|
|
|
+ $lower = max((int) $user->uMarkAllRead, (int) $topic['mf_mark_all_read'], (int) $topic['mt_last_read']); //????
|
|
|
|
+ if ($timeMax > $lower) {
|
|
|
|
+ $vars[':read'] = $timeMax;
|
|
|
|
+ $flag = true;
|
|
|
|
+ }
|
|
|
|
+ $upper = max($lower, (int) $topic['mt_last_visit'], (int) $user->lastVisit); //????
|
|
|
|
+ if ($topic['last_post'] > $upper) {
|
|
|
|
+ $vars[':visit'] = $topic['last_post'];
|
|
|
|
+ $flag = true;
|
|
|
|
+ }
|
|
|
|
+ if ($flag) {
|
|
|
|
+ if (empty($topic['mt_last_read']) && empty($topic['mt_last_visit'])) {
|
|
|
|
+ $this->c->DB->exec('INSERT INTO ::mark_of_topic (uid, tid, mt_last_visit, mt_last_read)
|
|
|
|
+ SELECT ?i:uid, ?i:tid, ?i:visit, ?i:read
|
|
|
|
+ FROM ::groups
|
|
|
|
+ WHERE NOT EXISTS (SELECT 1
|
|
|
|
+ FROM ::mark_of_topic
|
|
|
|
+ WHERE uid=?i:uid AND tid=?i:tid)
|
|
|
|
+ LIMIT 1', $vars);
|
|
|
|
+ } else {
|
|
|
|
+ $this->c->DB->exec('UPDATE ::mark_of_topic
|
|
|
|
+ SET mt_last_visit=?i:visit, mt_last_read=?i:read
|
|
|
|
+ WHERE uid=?i:uid AND tid=?i:tid', $vars);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return $this;
|
|
return $this;
|
|
}
|
|
}
|
|
}
|
|
}
|