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.

notificationsmanagerview.class.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. declare(strict_types=1);
  3. class NotificationsManagerView
  4. {
  5. private static $Settings;
  6. public static function load_js()
  7. {
  8. $ENV = ENV::go();
  9. # Adapted from design/privateheader.php
  10. $Scripts = [
  11. 'vendor/noty/packaged/jquery.noty.packaged.min',
  12. 'vendor/noty/layouts/bottomRight',
  13. 'vendor/noty/themes/relax',
  14. 'user_notifications'
  15. ];
  16. foreach ($Scripts as $Script) {
  17. echo View::pushAsset(
  18. "$ENV->STATIC_SERVER/functions/$Script.js",
  19. 'script'
  20. );
  21. }
  22. }
  23. public static function render_settings($Settings)
  24. {
  25. $ENV = ENV::go();
  26. self::$Settings = $Settings; ?>
  27. <tr>
  28. <td class="label">
  29. <strong>News Announcements</strong>
  30. </td>
  31. <td>
  32. <?php self::render_checkbox(NotificationsManager::NEWS); ?>
  33. </td>
  34. </tr>
  35. <tr>
  36. <td class="label">
  37. <strong>Blog Announcements</strong>
  38. </td>
  39. <td>
  40. <?php self::render_checkbox(NotificationsManager::BLOG); ?>
  41. </td>
  42. </tr>
  43. <tr>
  44. <td class="label">
  45. <strong>Inbox Messages</strong>
  46. </td>
  47. <td>
  48. <?php self::render_checkbox(NotificationsManager::INBOX, true); ?>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="label tooltip"
  53. title="Notify when you receive a new private message from <?= $ENV->SITE_NAME ?> staff">
  54. <strong>Staff Messages</strong>
  55. </td>
  56. <td>
  57. <?php self::render_checkbox(NotificationsManager::STAFFPM, false, false); ?>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="label">
  62. <strong>Thread Subscriptions</strong>
  63. </td>
  64. <td>
  65. <?php self::render_checkbox(NotificationsManager::SUBSCRIPTIONS, false, false); ?>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td class="label tooltip" title="Notify whenever someone quotes you in the forums">
  70. <strong>Quote Notifications</strong>
  71. </td>
  72. <td>
  73. <?php self::render_checkbox(NotificationsManager::QUOTES); ?>
  74. </td>
  75. </tr>
  76. <?php if (check_perms('site_torrents_notify')) { ?>
  77. <tr>
  78. <td class="label tooltip" title="Notify when your torrent notification filters are triggered">
  79. <strong>Torrent Notifications</strong>
  80. </td>
  81. <td>
  82. <?php self::render_checkbox(NotificationsManager::TORRENTS, true, false); ?>
  83. </td>
  84. </tr>
  85. <?php } ?>
  86. <tr>
  87. <td class="label tooltip" title="Notify when a torrent is added to a subscribed collage">
  88. <strong>Collage Subscriptions</strong>
  89. </td>
  90. <td>
  91. <?php self::render_checkbox(NotificationsManager::COLLAGES. false, false); ?>
  92. </td>
  93. </tr>
  94. <?php
  95. }
  96. private static function render_checkbox($Name, $Traditional = false)
  97. {
  98. $Checked = self::$Settings[$Name];
  99. $PopupChecked = $Checked === NotificationsManager::OPT_POPUP || !isset($Checked) ? ' checked="checked"' : '';
  100. $TraditionalChecked = $Checked === NotificationsManager::OPT_TRADITIONAL ? ' checked="checked"' : ''; ?>
  101. <label>
  102. <input type="checkbox" name="notifications_<?=$Name?>_popup"
  103. id="notifications_<?=$Name?>_popup" <?=$PopupChecked?> />
  104. Pop-up
  105. </label>
  106. <?php if ($Traditional) { ?>
  107. <label>
  108. <input type="checkbox" name="notifications_<?=$Name?>_traditional"
  109. id="notifications_<?=$Name?>_traditional" <?=$TraditionalChecked?> />
  110. Traditional
  111. </label>
  112. <?php
  113. }
  114. }
  115. public static function format_traditional($Contents)
  116. {
  117. return "<a href=\"$Contents[url]\">$Contents[message]</a>";
  118. }
  119. }