diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e5794ffc..01449d0c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Some security improvements 🔑 [\#1503](https://github.com/torrentpier/torrentpier/pull/1503) ([belomaxorka](https://github.com/belomaxorka)) - Some security enhancements (Part 2) [\#1505](https://github.com/torrentpier/torrentpier/pull/1505) ([belomaxorka](https://github.com/belomaxorka)) - Some improvements for integrity checker [\#1501](https://github.com/torrentpier/torrentpier/pull/1501) ([belomaxorka](https://github.com/belomaxorka)) +- Hide vote button in topic if guest [\#1507](https://github.com/torrentpier/torrentpier/pull/1507) ([belomaxorka](https://github.com/belomaxorka)) - Minor improvements [\#1502](https://github.com/torrentpier/torrentpier/pull/1502), [\#1506](https://github.com/torrentpier/torrentpier/pull/1506) ([belomaxorka](https://github.com/belomaxorka)) - New Crowdin updates [\#1504](https://github.com/torrentpier/torrentpier/pull/1504) ([Exileum](https://github.com/Exileum)) diff --git a/library/ajax/thanks.php b/library/ajax/thanks.php index 41b1646a2..ec301dddd 100644 --- a/library/ajax/thanks.php +++ b/library/ajax/thanks.php @@ -27,37 +27,36 @@ if (!$topic_id = (int)$this->request['topic_id']) { switch ($mode) { case 'add': - if (!IS_GUEST) { - if (DB()->fetch_row('SELECT poster_id FROM ' . BB_BT_TORRENTS . " WHERE topic_id = $topic_id AND poster_id = " . $userdata['user_id'])) { - $this->ajax_die($lang['LIKE_OWN_POST']); - } - - if (DB()->fetch_row('SELECT topic_id FROM ' . BB_THX . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id'])) { - $this->ajax_die($lang['LIKE_ALREADY']); - } - - $columns = 'topic_id, user_id, time'; - $values = "$topic_id, {$userdata['user_id']}, " . TIMENOW; - DB()->query('INSERT IGNORE INTO ' . BB_THX . " ($columns) VALUES ($values)"); - break; - } else { + if (IS_GUEST) { $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']); } + if (DB()->fetch_row('SELECT poster_id FROM ' . BB_BT_TORRENTS . " WHERE topic_id = $topic_id AND poster_id = " . $userdata['user_id'])) { + $this->ajax_die($lang['LIKE_OWN_POST']); + } + + if (DB()->fetch_row('SELECT topic_id FROM ' . BB_THX . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id'])) { + $this->ajax_die($lang['LIKE_ALREADY']); + } + + $columns = 'topic_id, user_id, time'; + $values = "$topic_id, {$userdata['user_id']}, " . TIMENOW; + DB()->query('INSERT IGNORE INTO ' . BB_THX . " ($columns) VALUES ($values)"); + break; case 'get': - if (!IS_GUEST || $bb_cfg['tor_thanks_list_guests']) { - $sql = DB()->fetch_rowset('SELECT u.username, u.user_rank, u.user_id, t.* FROM ' . BB_THX . ' t, ' . BB_USERS . " u WHERE t.topic_id = $topic_id AND t.user_id = u.user_id"); - - $user_list = []; - foreach ($sql as $row) { - $user_list[] = '' . profile_url($row) . ' (' . bb_date($row['time']) . ')'; - } - - $this->response['html'] = join(', ', $user_list) ?: $lang['NO_LIKES']; - break; - } else { + if (IS_GUEST && !$bb_cfg['tor_thanks_list_guests']) { $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']); } + + $sql = DB()->fetch_rowset('SELECT u.username, u.user_rank, u.user_id, t.* FROM ' . BB_THX . ' t, ' . BB_USERS . " u WHERE t.topic_id = $topic_id AND t.user_id = u.user_id"); + + $user_list = []; + foreach ($sql as $row) { + $user_list[] = '' . profile_url($row) . ' (' . bb_date($row['time']) . ')'; + } + + $this->response['html'] = join(', ', $user_list) ?: $lang['NO_LIKES']; + break; default: $this->ajax_die('Invalid mode: ' . $mode); } diff --git a/styles/templates/default/viewtopic_attach.tpl b/styles/templates/default/viewtopic_attach.tpl index 9abc82e9d..0b1703ef1 100644 --- a/styles/templates/default/viewtopic_attach.tpl +++ b/styles/templates/default/viewtopic_attach.tpl @@ -459,14 +459,16 @@ $('#tor-filelist-btn').click(function () { }
- +
+
+