Vote button code improvements (#1142)

This commit is contained in:
Roman Kelesidis 2023-11-21 00:57:48 +07:00 committed by GitHub
commit a4be40db9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View file

@ -5,7 +5,7 @@
**Merged pull requests:** **Merged pull requests:**
- Vote button code improvements [\#1140](https://github.com/torrentpier/torrentpier/pull/1140) ([belomaxorka](https://github.com/belomaxorka)) - Vote button code improvements [\#1140](https://github.com/torrentpier/torrentpier/pull/1140), [\#1142](https://github.com/torrentpier/torrentpier/pull/1142) ([belomaxorka](https://github.com/belomaxorka))
- Vote button and v2 file list topic url display [\#1138](https://github.com/torrentpier/torrentpier/pull/1138) ([kovalensky](https://github.com/kovalensky)) - Vote button and v2 file list topic url display [\#1138](https://github.com/torrentpier/torrentpier/pull/1138) ([kovalensky](https://github.com/kovalensky))
- Removed topic watch useless code [\#1137](https://github.com/torrentpier/torrentpier/pull/1137) ([belomaxorka](https://github.com/belomaxorka)) - Removed topic watch useless code [\#1137](https://github.com/torrentpier/torrentpier/pull/1137) ([belomaxorka](https://github.com/belomaxorka))
- Fixed topic_watch array key name [\#1136](https://github.com/torrentpier/torrentpier/pull/1136) ([belomaxorka](https://github.com/belomaxorka)) - Fixed topic_watch array key name [\#1136](https://github.com/torrentpier/torrentpier/pull/1136) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -14,7 +14,7 @@ if (!defined('IN_AJAX')) {
global $bb_cfg, $lang, $userdata; global $bb_cfg, $lang, $userdata;
if (!$bb_cfg['tor_thank']) { if (!$bb_cfg['tor_thank']) {
$this->ajax_die($lang['DISABLED']); $this->ajax_die($lang['MODULE_OFF']);
} }
$mode = (string)$this->request['mode']; $mode = (string)$this->request['mode'];
@ -22,14 +22,14 @@ $topic_id = (int)$this->request['topic_id'];
switch ($mode) { switch ($mode) {
case 'add': case 'add':
if (DB()->fetch_row('SELECT * FROM ' . BB_THX . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id'])) {
$this->ajax_die($lang['LIKE_ALREADY']);
}
if (DB()->fetch_row('SELECT poster_id FROM ' . BB_BT_TORRENTS . " WHERE topic_id = $topic_id AND poster_id = " . $userdata['user_id'])) { 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']); $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'; $columns = 'topic_id, user_id, time';
$values = "$topic_id, {$userdata['user_id']}, " . TIMENOW; $values = "$topic_id, {$userdata['user_id']}, " . TIMENOW;
DB()->query('INSERT IGNORE INTO ' . BB_THX . " ($columns) VALUES ($values)"); DB()->query('INSERT IGNORE INTO ' . BB_THX . " ($columns) VALUES ($values)");
@ -51,3 +51,5 @@ switch ($mode) {
default: default:
$this->ajax_die('Invalid mode'); $this->ajax_die('Invalid mode');
} }
$this->response['mode'] = $mode;

View file

@ -454,7 +454,6 @@ $('#tor-filelist-btn').click(function(){
} }
} }
</script> </script>
<div id="thx-block"> <div id="thx-block">
<div id="thx-btn-div"> <div id="thx-btn-div">
<input id="thx-btn" type="button" class="bold" style="width: 200px;" value='{$lang['THANK_TOPIC']}'/> <input id="thx-btn" type="button" class="bold" style="width: 200px;" value='{$lang['THANK_TOPIC']}'/>