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

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