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.

notify_edit.php 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. if (!check_perms('site_torrents_notify')) {
  3. error(403);
  4. }
  5. View::show_header('Manage notifications', 'jquery.validate,form_validate');
  6. ?>
  7. <div class="thin">
  8. <div class="header">
  9. <h2>Notify me of all new torrents with&hellip;</h2>
  10. <div class="linkbox">
  11. <a href="torrents.php?action=notify" class="brackets">View notifications</a>
  12. </div>
  13. </div>
  14. <?php
  15. $DB->query("
  16. SELECT
  17. ID,
  18. Label,
  19. Artists,
  20. ExcludeVA,
  21. NewGroupsOnly,
  22. Tags,
  23. NotTags,
  24. ReleaseTypes,
  25. Categories,
  26. Formats,
  27. Encodings,
  28. Media,
  29. FromYear,
  30. ToYear,
  31. Users
  32. FROM users_notify_filters
  33. WHERE UserID=$LoggedUser[ID]");
  34. $NumFilters = $DB->record_count();
  35. $Notifications = $DB->to_array();
  36. $Notifications[] = array(
  37. 'ID' => false,
  38. 'Label' => '',
  39. 'Artists' => '',
  40. 'ExcludeVA' => false,
  41. 'NewGroupsOnly' => true,
  42. 'Tags' => '',
  43. 'NotTags' => '',
  44. 'ReleaseTypes' => '',
  45. 'Categories' => '',
  46. 'Formats' => '',
  47. 'Encodings' => '',
  48. 'Media' => '',
  49. 'FromYear' => '',
  50. 'ToYear' => '',
  51. 'Users' => ''
  52. );
  53. $i = 0;
  54. foreach ($Notifications as $N) { // $N stands for Notifications
  55. $i++;
  56. $NewFilter = $N['ID'] === false;
  57. $N['Artists'] = implode(', ', explode('|', substr($N['Artists'], 1, -1)));
  58. $N['Tags'] = implode(', ', explode('|', substr($N['Tags'], 1, -1)));
  59. $N['NotTags'] = implode(', ', explode('|', substr($N['NotTags'], 1, -1)));
  60. $N['ReleaseTypes'] = explode('|', substr($N['ReleaseTypes'], 1, -1));
  61. $N['Categories'] = explode('|', substr($N['Categories'], 1, -1));
  62. $N['Formats'] = explode('|', substr($N['Formats'], 1, -1));
  63. $N['Encodings'] = explode('|', substr($N['Encodings'], 1, -1));
  64. $N['Media'] = explode('|', substr($N['Media'], 1, -1));
  65. $N['Users'] = explode('|', substr($N['Users'], 1, -1));
  66. $Usernames = '';
  67. foreach ($N['Users'] as $UserID) {
  68. $UserInfo = Users::user_info($UserID);
  69. $Usernames .= $UserInfo['Username'] . ', ';
  70. }
  71. $Usernames = rtrim($Usernames, ', ');
  72. if ($N['FromYear'] === 0) {
  73. $N['FromYear'] = '';
  74. }
  75. if ($N['ToYear'] === 0) {
  76. $N['ToYear'] = '';
  77. }
  78. if ($NewFilter && $NumFilters > 0) {
  79. ?>
  80. <br><br>
  81. <h3>Create a new notification filter</h3>
  82. <?php
  83. } elseif ($NumFilters > 0) { ?>
  84. <h3>
  85. <a
  86. href="feeds.php?feed=torrents_notify_<?=$N['ID']?>_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode($N['Label'])?>"><img
  87. src="<?=STATIC_SERVER?>/common/symbols/rss.png"
  88. alt="RSS feed"></a>
  89. <?=display_str($N['Label'])?>
  90. <a href="user.php?action=notify_delete&amp;id=<?=$N['ID']?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
  91. onclick="return confirm('Are you sure you want to delete this notification filter?')" class="brackets">Delete</a>
  92. <a data-toggle-target="#filter_<?=$N['ID']?>"
  93. class="brackets">Show</a>
  94. </h3>
  95. <?php } ?>
  96. <form
  97. class="box pad slight_margin <?=($NewFilter ? 'create_form' : 'edit_form')?>"
  98. id="<?=($NewFilter ? 'filter_form' : '')?>"
  99. name="notification" action="user.php" method="post">
  100. <input type="hidden" name="formid" value="<?=$i?>">
  101. <input type="hidden" name="action" value="notify_handle">
  102. <input type="hidden" name="auth"
  103. value="<?=$LoggedUser['AuthKey']?>">
  104. <?php if (!$NewFilter) { ?>
  105. <input type="hidden" name="id<?=$i?>"
  106. value="<?=$N['ID']?>">
  107. <?php } ?>
  108. <table <?=(!$NewFilter ? 'id="filter_'.$N['ID'].'" class="layout hidden"' : 'class="layout"')?>>
  109. <?php if ($NewFilter) { ?>
  110. <tr>
  111. <td class="label">
  112. <strong>Notification filter name</strong>
  113. <strong class="important_text">*</strong>
  114. </td>
  115. <td>
  116. <input type="text" class="required" name="label<?=$i?>"
  117. style="width: 100%;">
  118. <p class="min_padding">A name for the notification filter set to tell different filters apart</p>
  119. </td>
  120. </tr>
  121. <!--
  122. <tr>
  123. <td colspan="2" class="center">
  124. <strong>All fields below here are optional</strong>
  125. </td>
  126. </tr>
  127. -->
  128. <?php } ?>
  129. <tr>
  130. <td class="label"><strong>One of these artists</strong></td>
  131. <td>
  132. <textarea name="artists<?=$i?>" style="width: 100%;"
  133. rows="5"><?=display_str($N['Artists'])?></textarea>
  134. <p class="min_padding">Comma-separated list, e.g., Yumeno Aika, Pink Pineapple</p>
  135. <!--
  136. <input type="checkbox" name="excludeva<?=$i?>"
  137. id="excludeva_<?=$N['ID']?>" <?php if ($N['ExcludeVA'] === '1') {
  138. echo ' checked="checked"';
  139. } ?>>
  140. <label
  141. for="excludeva_<?=$N['ID']?>">Exclude
  142. Various Artists releases</label>
  143. -->
  144. </td>
  145. </tr>
  146. <tr>
  147. <td class="label"><strong>One of these users</strong></td>
  148. <td>
  149. <textarea name="users<?=$i?>" style="width: 100%;"
  150. rows="5"><?=display_str($Usernames)?></textarea>
  151. <p class="min_padding">Comma-separated list of usernames</p>
  152. </td>
  153. </tr>
  154. <tr>
  155. <td class="label"><strong>At least one of these tags</strong></td>
  156. <td>
  157. <textarea name="tags<?=$i?>" style="width: 100%;"
  158. rows="2"><?=display_str($N['Tags'])?></textarea>
  159. <p class="min_padding">Comma-separated list, e.g., paizuri, nakadashi
  160. </p>
  161. </td>
  162. </tr>
  163. <tr>
  164. <td class="label"><strong>None of these tags</strong></td>
  165. <td>
  166. <textarea name="nottags<?=$i?>" style="width: 100%;"
  167. rows="2"><?=display_str($N['NotTags'])?></textarea>
  168. <p class="min_padding">Comma-separated list, e.g., paizuri, nakadashi
  169. </p>
  170. </td>
  171. </tr>
  172. <tr>
  173. <td class="label"><strong>Only these categories</strong></td>
  174. <td>
  175. <?php foreach ($Categories as $Category) { ?>
  176. <input type="checkbox" name="categories<?=$i?>[]"
  177. id="<?=$Category?>_<?=$N['ID']?>"
  178. value="<?=$Category?>" <?php if (in_array($Category, $N['Categories'])) {
  179. echo ' checked="checked"';
  180. } ?>>
  181. <label
  182. for="<?=$Category?>_<?=$N['ID']?>"><?=$Category?></label><br />
  183. <?php } ?>
  184. </td>
  185. </tr>
  186. <tr>
  187. <td class="label"><strong>Only these media</strong></td>
  188. <td>
  189. <?php foreach ($Media as $Medium) { ?>
  190. <input type="checkbox" name="media<?=$i?>[]"
  191. id="<?=$Medium?>_<?=$N['ID']?>"
  192. value="<?=$Medium?>" <?php if (in_array($Medium, $N['Media'])) {
  193. echo ' checked="checked"';
  194. } ?>>
  195. <label
  196. for="<?=$Medium?>_<?=$N['ID']?>"><?=$Medium?></label><br />
  197. <?php } ?>
  198. </td>
  199. </tr>
  200. <tr>
  201. <td class="label"><strong>Only these media</strong></td>
  202. <td>
  203. <?php foreach ($MediaManga as $Medium) { ?>
  204. <input type="checkbox" name="media<?=$i?>[]"
  205. id="<?=$Medium?>_<?=$N['ID']?>"
  206. value="<?=$Medium?>" <?php if (in_array($Medium, $N['Media'])) {
  207. echo ' checked="checked"';
  208. } ?>>
  209. <label
  210. for="<?=$Medium?>_<?=$N['ID']?>"><?=$Medium?></label><br />
  211. <?php } ?>
  212. </td>
  213. </tr>
  214. <tr>
  215. <td class="label"><strong>Only new releases</strong></td>
  216. <td>
  217. <input type="checkbox" name="newgroupsonly<?=$i?>"
  218. id="newgroupsonly_<?=$N['ID']?>"
  219. <?php if ($N['NewGroupsOnly'] == '1') { # todo: Fix strict equality checking
  220. echo ' checked="checked"';
  221. } ?>>
  222. <label
  223. for="newgroupsonly_<?=$N['ID']?>">Only
  224. notify for new releases, not new formats</label>
  225. </td>
  226. </tr>
  227. <tr>
  228. <td colspan="2" class="center">
  229. <input type="submit"
  230. value="<?=($NewFilter ? 'Create' : 'Update')?>">
  231. </td>
  232. </tr>
  233. </table>
  234. </form>
  235. <?php
  236. } ?>
  237. </div>
  238. <?php View::show_footer();