BioTorrents.de’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.

donationsview.class.php 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. #declare(strict_types=1);
  3. class DonationsView
  4. {
  5. public static function render_mod_donations($UserID)
  6. {
  7. ?>
  8. <table class="layout box" id="donation_box">
  9. <tr class="colhead">
  10. <td colspan="2">
  11. Donor System (add points)
  12. </td>
  13. </tr>
  14. <tr>
  15. <td class="label">Value:</td>
  16. <td>
  17. <input type="text" name="donation_value" onkeypress="return isNumberKey(event);" />
  18. <select name="donation_currency">
  19. <option value="EUR">EUR</option>
  20. <option value="USD">USD</option>
  21. <option value="BTC">BTC</option>
  22. </select>
  23. </td>
  24. </tr>
  25. <tr>
  26. <td class="label">Reason:</td>
  27. <td><input type="text" class="wide_input_text" name="donation_reason" /></td>
  28. </tr>
  29. <tr>
  30. <td align="right" colspan="2">
  31. <input type="submit" name="donor_points_submit" value="Add donor points" />
  32. </td>
  33. </tr>
  34. </table>
  35. <table class="layout box" id="donor_points_box">
  36. <tr class="colhead">
  37. <td colspan="3" class="tooltip"
  38. title='Use this tool only when manually correcting values. If crediting donations normally, use the "Donor System (add points)" tool'>
  39. Donor System (modify values)
  40. </td>
  41. </tr>
  42. <tr>
  43. <td class="label tooltip" title="Active points determine a user's Donor Rank and do expire.">Active points:</td>
  44. <td><input type="text" name="donor_rank" onkeypress="return isNumberKey(event);"
  45. value="<?=Donations::get_rank($UserID)?>" /></td>
  46. </tr>
  47. <tr>
  48. <td class="label tooltip"
  49. title="Total points represent a user's overall total and never expire. Total points determines a user's Special Rank and Donor Leaderboard placement.">
  50. Total points:</td>
  51. <td><input type="text" name="total_donor_rank" onkeypress="return isNumberKey(event);"
  52. value="<?=Donations::get_total_rank($UserID)?>" /></td>
  53. </tr>
  54. <tr>
  55. <td class="label">Reason:</td>
  56. <td><input type="text" class="wide_input_text" name="reason" /></td>
  57. </tr>
  58. <tr>
  59. <td align="right" colspan="2">
  60. <input type="submit" name="donor_values_submit" value="Change point values" />
  61. </td>
  62. </tr>
  63. </table>
  64. <?php
  65. }
  66. public static function render_donor_stats($UserID)
  67. {
  68. $OwnProfile = G::$LoggedUser['ID'] === $UserID;
  69. if (check_perms("users_mod") || $OwnProfile || Donations::is_visible($UserID)) {
  70. ?>
  71. <div class="box box_info box_userinfo_donor_stats">
  72. <div class="head colhead_dark">Donor Statistics</div>
  73. <ul class="stats nobullet">
  74. <?php
  75. if (Donations::is_donor($UserID)) {
  76. if (check_perms('users_mod') || $OwnProfile) {
  77. ?>
  78. <li>
  79. Total donor points: <?=Donations::get_total_rank($UserID)?>
  80. </li>
  81. <?php
  82. } ?>
  83. <li>
  84. Current donor rank: <?=self::render_rank(Donations::get_rank($UserID), Donations::get_special_rank($UserID), true)?>
  85. </li>
  86. <li>
  87. Leaderboard position: <?=Donations::get_leaderboard_position($UserID)?>
  88. </li>
  89. <li>
  90. Last donated: <?=time_diff(Donations::get_donation_time($UserID))?>
  91. </li>
  92. <li>
  93. Rank expires: <?=(Donations::get_rank_expiration($UserID))?>
  94. </li>
  95. <?php
  96. } else { ?>
  97. <li>
  98. This user hasn't donated.
  99. </li>
  100. <?php } ?>
  101. </ul>
  102. </div>
  103. <?php
  104. }
  105. }
  106. public static function render_profile_rewards($EnabledRewards, $ProfileRewards)
  107. {
  108. for ($i = 1; $i <= 4; $i++) {
  109. if ($EnabledRewards['HasProfileInfo' . $i] && $ProfileRewards['ProfileInfo' . $i]) {
  110. ?>
  111. <div class="box">
  112. <div class="head">
  113. <span><?=!empty($ProfileRewards['ProfileInfoTitle' . $i]) ? display_str($ProfileRewards['ProfileInfoTitle' . $i]) : "Extra Profile " . ($i + 1)?></span>
  114. <span class="float_right"><a
  115. data-toggle-target="#profilediv_<?=$i?>"
  116. data-toggle-replace="Show" class="brackets">Hide</a></span>
  117. </div>
  118. <div class="pad profileinfo" id="profilediv_<?=$i?>">
  119. <?= Text::full_format($ProfileRewards['ProfileInfo' . $i]); ?>
  120. </div>
  121. </div>
  122. <?php
  123. }
  124. }
  125. }
  126. public static function render_donation_history($DonationHistory)
  127. {
  128. if (empty($DonationHistory)) {
  129. return;
  130. } ?>
  131. <div class="box" id="donation_history_box">
  132. <div class="head">
  133. Donation History <a data-toggle-target="#donation_history" class="brackets" style="float_right">Toggle</a>
  134. </div>
  135. <div class="hidden" id="donation_history">
  136. <table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
  137. <tbody>
  138. <tr class="colhead_dark">
  139. <td>
  140. <strong>Source</strong>
  141. </td>
  142. <td>
  143. <strong>Date</strong>
  144. </td>
  145. <td>
  146. <strong>Amount (EUR)</strong>
  147. </td>
  148. <td>
  149. <strong>Added Points</strong>
  150. </td>
  151. <td>
  152. <strong>Total Points</strong>
  153. </td>
  154. <td>
  155. <strong>Email</strong>
  156. </td>
  157. <td style="width: 30%;">
  158. <strong>Reason</strong>
  159. </td>
  160. </tr>
  161. <?php foreach ($DonationHistory as $Donation) { ?>
  162. <tr class="row">
  163. <td>
  164. <?=display_str($Donation['Source'])?>
  165. (<?=Users::format_username($Donation['AddedBy'])?>)
  166. </td>
  167. <td>
  168. <?=$Donation['Time']?>
  169. </td>
  170. <td>
  171. <?=$Donation['Amount']?>
  172. </td>
  173. <td>
  174. <?=$Donation['Rank']?>
  175. </td>
  176. <td>
  177. <?=$Donation['TotalRank']?>
  178. </td>
  179. <td>
  180. <?=display_str($Donation['Email'])?>
  181. </td>
  182. <td>
  183. <?=display_str($Donation['Reason'])?>
  184. </td>
  185. </tr>
  186. <?php
  187. } ?>
  188. </tbody>
  189. </table>
  190. </div>
  191. </div>
  192. <?php
  193. }
  194. public static function render_rank($Rank, $SpecialRank, $ShowOverflow = false)
  195. {
  196. if ($SpecialRank === 3) {
  197. $Display = '∞ [Diamond]';
  198. } else {
  199. $CurrentRank = $Rank >= MAX_RANK ? MAX_RANK : $Rank;
  200. $Overflow = $Rank - $CurrentRank;
  201. $Display = $CurrentRank;
  202. if ($Display === 5 || $Display === 6) {
  203. $Display--;
  204. }
  205. if ($ShowOverflow && $Overflow) {
  206. $Display .= " (+$Overflow)";
  207. }
  208. if ($Rank >= 6) {
  209. $Display .= ' [Gold]';
  210. } elseif ($Rank >= 4) {
  211. $Display .= ' [Silver]';
  212. } elseif ($Rank >= 3) {
  213. $Display .= ' [Bronze]';
  214. } elseif ($Rank >= 2) {
  215. $Display .= ' [Copper]';
  216. } elseif ($Rank >= 1) {
  217. $Display .= ' [Red]';
  218. }
  219. }
  220. echo $Display;
  221. }
  222. }