Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

request.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?
  2. $RequestTax = 0.1;
  3. // Minimum and default amount of upload to remove from the user when they vote.
  4. // Also change in static/functions/requests.js
  5. $MinimumVote = 20 * 1024 * 1024;
  6. /*
  7. * This is the page that displays the request to the end user after being created.
  8. */
  9. if (empty($_GET['id']) || !is_number($_GET['id'])) {
  10. json_die("failure");
  11. }
  12. $RequestID = (int)$_GET['id'];
  13. //First things first, lets get the data for the request.
  14. $Request = Requests::get_request($RequestID);
  15. if ($Request === false) {
  16. json_die("failure");
  17. }
  18. $CategoryID = $Request['CategoryID'];
  19. $Requestor = Users::user_info($Request['UserID']);
  20. $Filler = $Request['FillerID'] ? Users::user_info($Request['FillerID']) : null;
  21. //Convenience variables
  22. $IsFilled = !empty($Request['TorrentID']);
  23. $CanVote = !$IsFilled && check_perms('site_vote');
  24. if ($CategoryID == 0) {
  25. $CategoryName = 'Unknown';
  26. } else {
  27. $CategoryName = $Categories[$CategoryID - 1];
  28. }
  29. $JsonArtists = pullmediainfo(Requests::get_artists($RequestID));
  30. //Votes time
  31. $RequestVotes = Requests::get_votes_array($RequestID);
  32. $VoteCount = count($RequestVotes['Voters']);
  33. $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == 'Music' && $Request['Year'] == 0)));
  34. $UserCanEdit = (!$IsFilled && $LoggedUser['ID'] == $Request['UserID'] && $VoteCount < 2);
  35. $CanEdit = ($UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests'));
  36. $JsonTopContributors = array();
  37. $VoteMax = ($VoteCount < 5 ? $VoteCount : 5);
  38. for ($i = 0; $i < $VoteMax; $i++) {
  39. $User = array_shift($RequestVotes['Voters']);
  40. $JsonTopContributors[] = array(
  41. 'userId' => (int)$User['UserID'],
  42. 'userName' => $User['Username'],
  43. 'bounty' => (int)$User['Bounty']
  44. );
  45. }
  46. reset($RequestVotes['Voters']);
  47. list($NumComments, $Page, $Thread) = Comments::load('requests', $RequestID, false);
  48. $JsonRequestComments = array();
  49. foreach ($Thread as $Key => $Post) {
  50. list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
  51. list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
  52. $JsonRequestComments[] = array(
  53. 'postId' => (int)$PostID,
  54. 'authorId' => (int)$AuthorID,
  55. 'name' => $Username,
  56. 'donor' => ($Donor == 1),
  57. 'warned' => !is_null($Warned),
  58. 'enabled' => ($Enabled == 2 ? false : true),
  59. 'class' => Users::make_class_string($PermissionID),
  60. 'addedTime' => $AddedTime,
  61. 'avatar' => $Avatar,
  62. 'comment' => Text::full_format($Body),
  63. 'editedUserId' => (int)$EditedUserID,
  64. 'editedUsername' => $EditedUsername,
  65. 'editedTime' => $EditedTime
  66. );
  67. }
  68. $JsonTags = array();
  69. foreach ($Request['Tags'] as $Tag) {
  70. $JsonTags[] = $Tag;
  71. }
  72. json_die('success', array(
  73. 'requestId' => (int)$RequestID,
  74. 'requestorId' => (int)$Request['UserID'],
  75. 'requestorName' => $Requestor['Username'],
  76. 'isBookmarked' => Bookmarks::has_bookmarked('request', $RequestID),
  77. 'requestTax' => (float)$RequestTax,
  78. 'timeAdded' => $Request['TimeAdded'],
  79. 'canEdit' => (bool)$CanEdit,
  80. 'canVote' => (bool)$CanVote,
  81. 'minimumVote' => (int)$MinimumVote,
  82. 'voteCount' => (int)$VoteCount,
  83. 'lastVote' => $Request['LastVote'],
  84. 'topContributors' => $JsonTopContributors,
  85. 'totalBounty' => (int)$RequestVotes['TotalBounty'],
  86. 'categoryId' => (int)$CategoryID,
  87. 'categoryName' => $CategoryName,
  88. 'title' => $Request['Title'],
  89. 'year' => (int)$Request['Year'],
  90. 'image' => $Request['Image'],
  91. 'bbDescription' => $Request['Description'],
  92. 'description' => Text::full_format($Request['Description']),
  93. 'artists' => $JsonArtists,
  94. 'isFilled' => (bool)$IsFilled,
  95. 'fillerId' => (int)$Request['FillerID'],
  96. 'fillerName' => $Filler ? $Filler['Username'] : '',
  97. 'torrentId' => (int)$Request['TorrentID'],
  98. 'timeFilled' => $Request['TimeFilled'],
  99. 'tags' => $JsonTags,
  100. 'comments' => $JsonRequestComments,
  101. 'commentPage' => (int)$Page,
  102. 'commentPages' => (int)ceil($NumComments / TORRENT_COMMENTS_PER_PAGE)
  103. ));
  104. ?>