From 5e691a0279ba95956603c7aaba030192159294dc Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 10 Feb 2024 21:14:19 +0700 Subject: [PATCH] Revert "Minor improvements (#1395)" This reverts commit 679d422a2a3a7d438b907b827ec92e81d45be8d8. --- CHANGELOG.md | 2 +- install/sql/mysql.sql | 4 +-- library/includes/functions.php | 41 ++++++++++------------- library/includes/torrent_show_dl_list.php | 2 +- viewtopic.php | 30 ++++++++--------- 5 files changed, 36 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfdddae85..2f83c59f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ - Fixed issue with poll_users cleaning at every cron job startup [\#1390](https://github.com/torrentpier/torrentpier/pull/1390) ([belomaxorka](https://github.com/belomaxorka)) - Improved word censor 🤐 [\#1393](https://github.com/torrentpier/torrentpier/pull/1393) ([belomaxorka](https://github.com/belomaxorka)) - Used hashing for filenames generation [\#1385](https://github.com/torrentpier/torrentpier/pull/1385) ([belomaxorka](https://github.com/belomaxorka)) -- Minor improvements [\#1382](https://github.com/torrentpier/torrentpier/pull/1382), [\#1383](https://github.com/torrentpier/torrentpier/pull/1383), [\#1391](https://github.com/torrentpier/torrentpier/pull/1391), [\#1394](https://github.com/torrentpier/torrentpier/pull/1394), [\#1395](https://github.com/torrentpier/torrentpier/pull/1395) ([belomaxorka](https://github.com/belomaxorka)) +- Minor improvements [\#1382](https://github.com/torrentpier/torrentpier/pull/1382), [\#1383](https://github.com/torrentpier/torrentpier/pull/1383), [\#1391](https://github.com/torrentpier/torrentpier/pull/1391), [\#1394](https://github.com/torrentpier/torrentpier/pull/1394) ([belomaxorka](https://github.com/belomaxorka)) - Some bugfixes [\#1380](https://github.com/torrentpier/torrentpier/pull/1380) ([belomaxorka](https://github.com/belomaxorka)) - New Crowdin updates [\#1384](https://github.com/torrentpier/torrentpier/pull/1384), [\#1389](https://github.com/torrentpier/torrentpier/pull/1389), [\#1392](https://github.com/torrentpier/torrentpier/pull/1392) ([Exileum](https://github.com/Exileum)) diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 5f98cebda..b79dd72e0 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -548,9 +548,9 @@ VALUES ('allow_autologin', '1'), ('seed_bonus_points', ''), ('seed_bonus_tor_size', '0'), ('seed_bonus_user_regdate', '0'), - ('site_desc', 'Bull-powered BitTorrent tracker engine'), + ('site_desc', 'A little text to describe your forum'), ('sitemap_time', ''), - ('sitename', 'TorrentPier'), + ('sitename', 'TorrentPier - Bull-powered BitTorrent tracker engine'), ('smilies_path', 'styles/images/smiles'), ('static_sitemap', ''), ('topics_per_page', '50'), diff --git a/library/includes/functions.php b/library/includes/functions.php index ec26fcc4a..ff43a727c 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2187,28 +2187,19 @@ function profile_url(array $data, bool $target_blank = false): string $username = $data['username']; $user_rank = $data['user_rank']; - if (!isset($user_id)) { - throw new InvalidArgumentException('Missing argument: user_id'); - } - if (!isset($username)) { - throw new InvalidArgumentException('Missing argument: username'); - } - if (!isset($user_rank)) { - throw new InvalidArgumentException('Missing argument: user_rank'); - } - if (!$ranks = $datastore->get('ranks')) { $datastore->update('ranks'); $ranks = $datastore->get('ranks'); } - $title = ''; - $style = 'colorUser'; + $title = $style = ''; if (isset($ranks[$user_rank])) { $title = $ranks[$user_rank]['rank_title']; - if ($bb_cfg['color_nick']) { - $style = $ranks[$user_rank]['rank_style']; - } + $style = $ranks[$user_rank]['rank_style']; + } + + if (empty($username)) { + $username = $lang['GUEST']; } if (empty($title)) { @@ -2219,6 +2210,14 @@ function profile_url(array $data, bool $target_blank = false): string }; } + if (empty($style)) { + $style = 'colorUser'; + } + + if (!$bb_cfg['color_nick']) { + $style = ''; + } + $profile = '' . $username . ''; if (!in_array($user_id, explode(',', EXCLUDED_USERS))) { $target_blank = $target_blank ? ' target="_blank" ' : ''; @@ -2291,24 +2290,20 @@ function is_gold($type): string case TOR_TYPE_SILVER: $is_gold = '' . $lang['SILVER'] . ' '; break; + default: + break; } return $is_gold; } -/** - * Update atom feed - * - * @param string $type - * @param $id - * @return void - */ -function update_atom(string $type, $id): void +function update_atom($type, $id) { switch ($type) { case 'user': \TorrentPier\Legacy\Atom::update_user_feed($id, get_username($id)); break; + case 'topic': $topic_poster = (int)DB()->fetch_row("SELECT topic_poster FROM " . BB_TOPICS . " WHERE topic_id = $id LIMIT 1", 'topic_poster'); \TorrentPier\Legacy\Atom::update_user_feed($topic_poster, get_username($topic_poster)); diff --git a/library/includes/torrent_show_dl_list.php b/library/includes/torrent_show_dl_list.php index 9ab75d8e4..6a95a72b9 100644 --- a/library/includes/torrent_show_dl_list.php +++ b/library/includes/torrent_show_dl_list.php @@ -72,7 +72,7 @@ if ($show_dl_list) { $dl_count[$u['user_status']] = $u['username']; } else { $u_prof_href = ($u['user_id'] == GUEST_UID) ? '#' : PROFILE_URL . $u['user_id'] . "#torrent"; - $dl_cat[$u['user_status']] .= '' . profile_url(['username' => $u['username'], 'user_id' => $u['user_id'], 'user_rank' => $u['user_rank']]) . ', '; + $dl_cat[$u['user_status']] .= '' . profile_url(['username' => $u['username'], 'user_rank' => $u['user_rank']]) . ', '; $dl_count[$u['user_status']]++; } } diff --git a/viewtopic.php b/viewtopic.php index a38dc4e81..e55a145ef 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -567,6 +567,9 @@ for ($i = 0; $i < $total_posts; $i++) { $poster_joined = !$poster_guest ? $lang['JOINED'] . ': ' . bb_date($postrow[$i]['user_regdate'], 'Y-m-d H:i') : ''; $poster_longevity = !$poster_guest ? delta_time($postrow[$i]['user_regdate']) : ''; $post_id = $postrow[$i]['post_id']; + $mc_type = (int)$postrow[$i]['mc_type']; + $mc_comment = $postrow[$i]['mc_comment']; + $mc_user_id = profile_url(['username' => $postrow[$i]['mc_username'], 'user_id' => $postrow[$i]['mc_user_id'], 'user_rank' => $postrow[$i]['mc_user_rank']]); $rg_id = $postrow[$i]['poster_rg_id'] ?: 0; $rg_avatar = get_avatar(GROUP_AVATAR_MASK . $rg_id, $postrow[$i]['rg_avatar_id']); @@ -655,18 +658,13 @@ for ($i = 0; $i < $total_posts; $i++) { $pg_row_class = !($i % 2) ? 'row2' : 'row1'; // Mod comment - if ($mc_type = (int)$postrow[$i]['mc_type']) { - $mc_comment = $postrow[$i]['mc_comment']; - $mc_user_id = profile_url(['username' => $postrow[$i]['mc_username'], 'user_id' => $postrow[$i]['mc_user_id'], 'user_rank' => $postrow[$i]['mc_user_rank']]); - - $mc_class = match ($mc_type) { - 1 => 'success', - 2 => 'info', - 3 => 'warning', - 4 => 'danger', - default => '', - }; - } + $mc_class = match ($mc_type) { + 1 => 'success', + 2 => 'info', + 3 => 'warning', + 4 => 'danger', + default => '', + }; $mc_select_type = []; foreach ($lang['MC_COMMENT'] as $key => $value) { $mc_select_type[$key] = $value['type']; @@ -713,10 +711,10 @@ for ($i = 0; $i < $total_posts; $i++) { 'POSTER_BIRTHDAY' => user_birthday_icon($postrow[$i]['user_birthday'], $postrow[$i]['user_id']), - 'MC_COMMENT' => isset($mc_comment) ? bbcode2html($mc_comment) : '', - 'MC_BBCODE' => $mc_comment ?? '', - 'MC_CLASS' => $mc_class ?? '', - 'MC_TITLE' => isset($mc_user_id) ? sprintf($lang['MC_COMMENT'][$mc_type]['title'], $mc_user_id) : '', + 'MC_COMMENT' => $mc_type ? bbcode2html($mc_comment) : '', + 'MC_BBCODE' => $mc_type ? $mc_comment : '', + 'MC_CLASS' => $mc_class, + 'MC_TITLE' => sprintf($lang['MC_COMMENT'][$mc_type]['title'], $mc_user_id), 'MC_SELECT_TYPE' => build_select("mc_type_$post_id", array_flip($mc_select_type), $mc_type), 'RG_AVATAR' => $rg_avatar,