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.

donationsview.class.php 7.2KB

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