diff --git a/classes/class_torrents.php b/classes/class_torrents.php index 6760fccc..dd14c1b4 100644 --- a/classes/class_torrents.php +++ b/classes/class_torrents.php @@ -476,6 +476,7 @@ public static function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLe } } + /** * Convenience function to allow for passing groups to Torrents::freeleech_torrents() * @@ -497,13 +498,13 @@ public static function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechT } } + /** * Check if the logged in user has an active freeleech token * * @param int $TorrentID * @return true if an active token exists */ - public static function has_token($TorrentID) { global $DB, $Cache, $LoggedUser; if (empty($LoggedUser) || empty($LoggedUser['ID'])) { @@ -523,5 +524,23 @@ public static function has_token($TorrentID) { return isset($TokenTorrents[$TorrentID]); } + + /** + * Check if the logged in user can use a freeleech token on this torrent + * + * @param int $Torrent + * @return true if user is allowed to use a token + */ + public static function can_use_token($Torrent) { + global $LoggedUser; + if (empty($LoggedUser) || empty($LoggedUser['ID'])) { + return false; + } + return ($LoggedUser['FLTokens'] > 0 + && $Torrent['Size'] < 1073741824 + && !$Torrent['PersonalFL'] + && empty($Torrent['FreeTorrent']) + && $LoggedUser['CanLeech'] == '1'); + } } ?> diff --git a/sections/forums/take_warn.php b/sections/forums/take_warn.php index d4056bed..1ad0ef55 100644 --- a/sections/forums/take_warn.php +++ b/sections/forums/take_warn.php @@ -32,11 +32,11 @@ $Subject = "You have received a verbal warning"; $PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage; $AdminComment = date("Y-m-d") . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n"; + Tools::update_user_notes($UserID, $AdminComment); } $DB->query("INSERT INTO users_warnings_forums (UserID, Comment) VALUES('$UserID', '" . db_string($AdminComment) . "') ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)"); -Tools::update_user_notes($UserID, $AdminComment); Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage); //edit the post