From b824718969c64a314ef2fb7c050cae9511afd856 Mon Sep 17 00:00:00 2001 From: Git Date: Thu, 7 Nov 2013 08:00:43 +0000 Subject: [PATCH] Empty commit --- classes/torrents.class.php | 24 ++++++++---- sections/ajax/torrentgroup.php | 6 +-- sections/rules/upload.php | 2 +- sections/torrents/details.php | 61 ++++++++----------------------- sections/torrents/functions.php | 59 +++++++++++++++--------------- static/functions/donor_titles.js | 63 +++++++++++++++----------------- 6 files changed, 93 insertions(+), 122 deletions(-) diff --git a/classes/torrents.class.php b/classes/torrents.class.php index 8ea1d95b..56f6b888 100644 --- a/classes/torrents.class.php +++ b/classes/torrents.class.php @@ -936,19 +936,27 @@ public static function get_reports($TorrentID) { $QueryID = G::$DB->get_query_id(); G::$DB->query(" SELECT - r.ID, - r.ReporterID, - r.Type, - r.UserComment, - r.ReportedTime - FROM reportsv2 AS r + ID, + ReporterID, + Type, + UserComment, + ReportedTime + FROM reportsv2 WHERE TorrentID = $TorrentID - AND Type != 'edited' AND Status != 'Resolved'"); - $Reports = G::$DB->to_array(); + $Reports = G::$DB->to_array(false, MYSQLI_ASSOC, false); G::$DB->set_query_id($QueryID); G::$Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0); } + if (!check_perms('admin_reports')) { + $Return = array(); + foreach ($Reports as $Report) { + if ($Report['Type'] !== 'edited') { + $Return[] = $Report; + } + } + return $Return; + } return $Reports; } } diff --git a/sections/ajax/torrentgroup.php b/sections/ajax/torrentgroup.php index 445c91eb..17dd432f 100644 --- a/sections/ajax/torrentgroup.php +++ b/sections/ajax/torrentgroup.php @@ -87,11 +87,7 @@ $FileList = implode('|||', $FileList); $Userinfo = Users::user_info($Torrent['UserID']); $Reports = Torrents::get_reports($Torrent['ID']); - if (count($Reports) > 0) { - $Torrent['Reported'] = true; - } else { - $Torrent['Reported'] = false; - } + $Torrent['Reported'] = count($Reports) > 0; $JsonTorrentList[] = array( 'id' => (int)$Torrent['ID'], 'media' => $Torrent['Media'], diff --git a/sections/rules/upload.php b/sections/rules/upload.php index 29ede711..0c545035 100644 --- a/sections/rules/upload.php +++ b/sections/rules/upload.php @@ -396,7 +396,7 @@
  • ↑_ 2.6.7. Include lineage information for each soundboard recording (see 2.3.10).
  • diff --git a/sections/torrents/details.php b/sections/torrents/details.php index 44189c71..a714ea5a 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -555,40 +555,12 @@ function filelist($Str) { $Reported = false; unset($ReportedTimes); - $Reports = $Cache->get_value("reports_torrent_$TorrentID"); - if ($Reports === false) { - $DB->query(" - SELECT - r.ID, - r.ReporterID, - r.Type, - r.UserComment, - r.ReportedTime - FROM reportsv2 AS r - WHERE TorrentID = $TorrentID - AND Status != 'Resolved'"); - $Reports = $DB->to_array(); - $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0); - } + $Reports = Torrents::get_reports($TorrentID); + $NumReports = count($Reports); - // used to see if we have any non-"edited log" reports to display - $NumNonEditedLogReports = 0; - - foreach ($Reports as $Report) { - if ($Report['Type'] != 'edited') { - $NumNonEditedLogReports += 1; - } - } - - /* for regular users, don't display the torrent reports table if there - * are 0 non-"edited log" reports. - * always let staff (e.g. permission "admin_reports") view "edited - * log" reports. - */ - if ($NumNonEditedLogReports > 0 || (check_perms('admin_reports') && $Reports)) { + if ($NumReports > 0) { $Reported = true; include(SERVER_ROOT.'/sections/reportsv2/array.php'); - $NumReports = check_perms('admin_reports') ? count($Reports) : $NumNonEditedLogReports; $ReportInfo = ' @@ -596,28 +568,27 @@ function filelist($Str) { "; foreach ($Reports as $Report) { - list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report; - - $Reporter = Users::user_info($ReporterID); - $ReporterName = $Reporter['Username']; - - if ($ReportType == 'edited' && !check_perms('admin_reports')) { - // Edited Log report and the viewing user does not have adequate permission - continue; + if (check_perms('admin_reports')) { + $ReporterID = $Report['ReporterID']; + $Reporter = Users::user_info($ReporterID); + $ReporterName = $Reporter['Username']; + $ReportLinks = "$ReporterNamereported it"; + } else { + $ReportLinks = 'Someone reported it'; } - if (array_key_exists($ReportType, $Types[$GroupCategoryID])) { - $ReportType = $Types[$GroupCategoryID][$ReportType]; - } elseif (array_key_exists($ReportType, $Types['master'])) { - $ReportType = $Types['master'][$ReportType]; + if (isset($Types[$GroupCategoryID][$Report['Type']])) { + $ReportType = $Types[$GroupCategoryID][$Report['Type']]; + } elseif (isset($Types['master'][$Report['Type']])) { + $ReportType = $Types['master'][$Report['Type']]; } else { //There was a type but it wasn't an option! $ReportType = $Types['master']['other']; } $ReportInfo .= " - '; } diff --git a/sections/torrents/functions.php b/sections/torrents/functions.php index c58fcf54..95d409ad 100644 --- a/sections/torrents/functions.php +++ b/sections/torrents/functions.php @@ -283,45 +283,44 @@ function filelist($Str) { $Reported = false; unset($ReportedTimes); - $Reports = $Cache->get_value("reports_torrent_$TorrentID"); - if ($Reports === false) { - $DB->query(" - SELECT - r.ID, - r.ReporterID, - r.Type, - r.UserComment, - r.ReportedTime - FROM reportsv2 AS r - WHERE TorrentID = $TorrentID - AND Type != 'edited' - AND Status != 'Resolved'"); - $Reports = $DB->to_array(); - $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0); - } - if (count($Reports) > 0) { + $Reports = Torrents::get_reports($TorrentID); + $NumReports = count($Reports); + + if ($NumReports > 0) { $Reported = true; - include(SERVER_ROOT . '/sections/reportsv2/array.php'); - $ReportInfo = "\n
    ".(check_perms('admin_reports') ? "$ReporterName reported it " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '": -
    '.$Text->full_format($ReportReason).'
    +
    $ReportLinks ".time_diff($Report['ReportedTime'], 2, true, true).' for the reason "'.$ReportType['title'].'": +
    '.$Text->full_format($Report['UserComment']).'
    \n\t\n\t\t\n\t"; + include(SERVER_ROOT.'/sections/reportsv2/array.php'); + $ReportInfo = ' +
    This torrent has " . count($Reports) . ' active ' . (count($Reports) > 1 ? 'reports' : 'report') . ":
    + + + "; foreach ($Reports as $Report) { - list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report; + if (check_perms('admin_reports')) { + $ReporterID = $Report['ReporterID']; + $Reporter = Users::user_info($ReporterID); + $ReporterName = $Reporter['Username']; + $ReportLinks = "$ReporterNamereported it"; + } else { + $ReportLinks = 'Someone reported it'; + } - $Reporter = Users::user_info($ReporterID); - $ReporterName = $Reporter['Username']; - - if (array_key_exists($ReportType, $Types[$GroupCategoryID])) { - $ReportType = $Types[$GroupCategoryID][$ReportType]; - } elseif (array_key_exists($ReportType, $Types['master'])) { - $ReportType = $Types['master'][$ReportType]; + if (isset($Types[$GroupCategoryID][$Report['Type']])) { + $ReportType = $Types[$GroupCategoryID][$Report['Type']]; + } elseif (isset($Types['master'][$Report['Type']])) { + $ReportType = $Types['master'][$Report['Type']]; } else { //There was a type but it wasn't an option! $ReportType = $Types['master']['other']; } - $ReportInfo .= "\n\t\n\t\t\n\t"; + $ReportInfo .= " + + + '; } - $ReportInfo .= "\n
    This torrent has '.$NumReports.' active '.($NumReports === 1 ? 'report' : 'reports').":
    " . (check_perms('admin_reports') ? "$ReporterName reported it " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":'; - $ReportInfo .= "\n\t\t\t
    " . $Text->full_format($ReportReason) . "
    \n\t\t
    $ReportLinks ".time_diff($Report['ReportedTime'], 2, true, true).' for the reason "'.$ReportType['title'].'": +
    '.$Text->full_format($Report['UserComment']).'
    +
    "; + $ReportInfo .= "\n\t\t"; } $CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear))); diff --git a/static/functions/donor_titles.js b/static/functions/donor_titles.js index 0b207e32..38f2a7e6 100644 --- a/static/functions/donor_titles.js +++ b/static/functions/donor_titles.js @@ -1,36 +1,33 @@ -(function ($) { - var remove_comma = false; - $(document).ready(function() { - $("#donor_title_prefix_preview").text($("#donor_title_prefix").val().trim() + " "); - $("#donor_title_suffix_preview").text(" " + $("#donor_title_suffix").val().trim()); +$(document).ready(function() { + if ($('#donor_title_prefix_preview').size() === 0) { + return; + } + $('#donor_title_prefix_preview').text($('#donor_title_prefix').val().trim() + ' '); + $('#donor_title_suffix_preview').text(' ' + $('#donor_title_suffix').val().trim()); - remove_comma = $("#donor_title_comma").attr("checked"); - if(remove_comma) { - $("#donor_title_comma_preview").text(""); - } else { - $("#donor_title_comma_preview").text(", "); - } - - $("#donor_title_prefix").keyup(function() { - if($(this).val().length <= 30) { - $("#donor_title_prefix_preview").text($(this).val().trim() + " "); - } - }); - - $("#donor_title_suffix").keyup(function() { - if($(this).val().length <= 30) { - $("#donor_title_suffix_preview").text(" " + $(this).val().trim()); - } - }); - - $("#donor_title_comma").change(function() { - remove_comma = $(this).attr("checked"); - if(remove_comma) { - $("#donor_title_comma_preview").text(""); - } else { - $("#donor_title_comma_preview").text(", "); - } - }); + if($('#donor_title_comma').attr('checked')) { + $('#donor_title_comma_preview').text(''); + } else { + $('#donor_title_comma_preview').text(', '); + } + $('#donor_title_prefix').keyup(function() { + if($(this).val().length <= 30) { + $('#donor_title_prefix_preview').text($(this).val().trim() + ' '); + } }); -}(jQuery)); + + $('#donor_title_suffix').keyup(function() { + if($(this).val().length <= 30) { + $('#donor_title_suffix_preview').text(' ' + $(this).val().trim()); + } + }); + + $('#donor_title_comma').change(function() { + if($(this).attr('checked')) { + $('#donor_title_comma_preview').text(''); + } else { + $('#donor_title_comma_preview').text(', '); + } + }); +});