Browse Source

Pare down notification filters

spaghetti 7 years ago
parent
commit
97ccf75ed0
2 changed files with 17 additions and 98 deletions
  1. 15
    50
      sections/user/notify_edit.php
  2. 2
    48
      sections/user/notify_handle.php

+ 15
- 50
sections/user/notify_edit.php View File

@@ -82,29 +82,29 @@ foreach ($Notifications as $N) { // $N stands for Notifications
82 82
   }
83 83
   if ($NewFilter && $NumFilters > 0) {
84 84
 ?>
85
-  <br /><br />
85
+  <br><br>
86 86
   <h3>Create a new notification filter</h3>
87 87
 <?  } elseif ($NumFilters > 0) { ?>
88 88
   <h3>
89
-    <a 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 src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed" /></a>
89
+    <a 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 src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed"></a>
90 90
     <?=display_str($N['Label'])?>
91 91
     <a href="user.php?action=notify_delete&amp;id=<?=$N['ID']?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to delete this notification filter?')" class="brackets">Delete</a>
92 92
     <a data-toggle-target="#filter_<?=$N['ID']?>" class="brackets">Show</a>
93 93
   </h3>
94 94
 <?  } ?>
95 95
   <form class="box pad slight_margin <?=($NewFilter ? 'create_form' : 'edit_form')?>" id="<?=($NewFilter ? 'filter_form' : '')?>" name="notification" action="user.php" method="post">
96
-    <input type="hidden" name="formid" value="<?=$i?>" />
97
-    <input type="hidden" name="action" value="notify_handle" />
98
-    <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
96
+    <input type="hidden" name="formid" value="<?=$i?>">
97
+    <input type="hidden" name="action" value="notify_handle">
98
+    <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>">
99 99
 <?  if (!$NewFilter) { ?>
100
-    <input type="hidden" name="id<?=$i?>" value="<?=$N['ID']?>" />
100
+    <input type="hidden" name="id<?=$i?>" value="<?=$N['ID']?>">
101 101
 <?  } ?>
102 102
     <table <?=(!$NewFilter ? 'id="filter_'.$N['ID'].'" class="layout hidden"' : 'class="layout"')?>>
103 103
 <?  if ($NewFilter) { ?>
104 104
       <tr>
105 105
         <td class="label"><strong>Notification filter name</strong></td>
106 106
         <td>
107
-          <input type="text" class="required" name="label<?=$i?>" style="width: 100%;" />
107
+          <input type="text" class="required" name="label<?=$i?>" style="width: 100%;">
108 108
           <p class="min_padding">A name for the notification filter set to tell different filters apart.</p>
109 109
         </td>
110 110
       </tr>
@@ -118,8 +118,8 @@ foreach ($Notifications as $N) { // $N stands for Notifications
118 118
         <td class="label"><strong>One of these artists</strong></td>
119 119
         <td>
120 120
           <textarea name="artists<?=$i?>" style="width: 100%;" rows="5"><?=display_str($N['Artists'])?></textarea>
121
-          <p class="min_padding">Comma-separated list&#8202;&mdash;&#8202;e.g. <em>Pink Floyd, Led Zeppelin, Neil Young</em></p>
122
-          <input type="checkbox" name="excludeva<?=$i?>" id="excludeva_<?=$N['ID']?>"<? if ($N['ExcludeVA'] == '1') { echo ' checked="checked"';} ?> />
121
+          <p class="min_padding">Comma-separated list&#8202;&mdash;&#8202;e.g. <em>Yumeno Aika, Pink Pineapple, Sayama Ai</em></p>
122
+          <input type="checkbox" name="excludeva<?=$i?>" id="excludeva_<?=$N['ID']?>"<? if ($N['ExcludeVA'] == '1') { echo ' checked="checked"';} ?>>
123 123
           <label for="excludeva_<?=$N['ID']?>">Exclude Various Artists releases</label>
124 124
         </td>
125 125
       </tr>
@@ -134,49 +134,22 @@ foreach ($Notifications as $N) { // $N stands for Notifications
134 134
         <td class="label"><strong>At least one of these tags</strong></td>
135 135
         <td>
136 136
           <textarea name="tags<?=$i?>" style="width: 100%;" rows="2"><?=display_str($N['Tags'])?></textarea>
137
-          <p class="min_padding">Comma-separated list&#8202;&mdash;&#8202;e.g. <em>rock, jazz, pop</em></p>
137
+          <p class="min_padding">Comma-separated list&#8202;&mdash;&#8202;e.g. <em>big.breasts, paizuri, nakadashi</em></p>
138 138
         </td>
139 139
       </tr>
140 140
       <tr>
141 141
         <td class="label"><strong>None of these tags</strong></td>
142 142
         <td>
143 143
           <textarea name="nottags<?=$i?>" style="width: 100%;" rows="2"><?=display_str($N['NotTags'])?></textarea>
144
-          <p class="min_padding">Comma-separated list&#8202;&mdash;&#8202;e.g. <em>rock, jazz, pop</em></p>
144
+          <p class="min_padding">Comma-separated list&#8202;&mdash;&#8202;e.g. <em>big.breasts, paizuri, nakadashi</em></p>
145 145
         </td>
146 146
       </tr>
147 147
       <tr>
148 148
         <td class="label"><strong>Only these categories</strong></td>
149 149
         <td>
150 150
 <?  foreach ($Categories as $Category) { ?>
151
-          <input type="checkbox" name="categories<?=$i?>[]" id="<?=$Category?>_<?=$N['ID']?>" value="<?=$Category?>"<? if (in_array($Category, $N['Categories'])) { echo ' checked="checked"';} ?> />
151
+          <input type="checkbox" name="categories<?=$i?>[]" id="<?=$Category?>_<?=$N['ID']?>" value="<?=$Category?>"<? if (in_array($Category, $N['Categories'])) { echo ' checked="checked"';} ?>>
152 152
           <label for="<?=$Category?>_<?=$N['ID']?>"><?=$Category?></label>
153
-<?  } ?>
154
-        </td>
155
-      </tr>
156
-      <tr>
157
-        <td class="label"><strong>Only these types</strong></td>
158
-        <td>
159
-<?  foreach ($ReleaseTypes as $ReleaseType) { ?>
160
-          <input type="checkbox" name="releasetypes<?=$i?>[]" id="<?=$ReleaseType?>_<?=$N['ID']?>" value="<?=$ReleaseType?>"<? if (in_array($ReleaseType, $N['ReleaseTypes'])) { echo ' checked="checked"';} ?> />
161
-          <label for="<?=$ReleaseType?>_<?=$N['ID']?>"><?=$ReleaseType?></label>
162
-<?  } ?>
163
-        </td>
164
-      </tr>
165
-      <tr>
166
-        <td class="label"><strong>Only these formats</strong></td>
167
-        <td>
168
-<?  foreach ($Formats as $Format) { ?>
169
-          <input type="checkbox" name="formats<?=$i?>[]" id="<?=$Format?>_<?=$N['ID']?>" value="<?=$Format?>"<? if (in_array($Format, $N['Formats'])) { echo ' checked="checked"';} ?> />
170
-          <label for="<?=$Format?>_<?=$N['ID']?>"><?=$Format?></label>
171
-<?  } ?>
172
-        </td>
173
-      </tr>
174
-      <tr>
175
-        <td class="label"><strong>Only these bitrates</strong></td>
176
-        <td>
177
-<?  foreach ($Bitrates as $Bitrate) { ?>
178
-          <input type="checkbox" name="bitrates<?=$i?>[]" id="<?=$Bitrate?>_<?=$N['ID']?>" value="<?=$Bitrate?>"<? if (in_array($Bitrate, $N['Encodings'])) { echo ' checked="checked"';} ?> />
179
-          <label for="<?=$Bitrate?>_<?=$N['ID']?>"><?=$Bitrate?></label>
180 153
 <?  } ?>
181 154
         </td>
182 155
       </tr>
@@ -184,29 +157,21 @@ foreach ($Notifications as $N) { // $N stands for Notifications
184 157
         <td class="label"><strong>Only these media</strong></td>
185 158
         <td>
186 159
 <?  foreach ($Media as $Medium) { ?>
187
-          <input type="checkbox" name="media<?=$i?>[]" id="<?=$Medium?>_<?=$N['ID']?>" value="<?=$Medium?>"<? if (in_array($Medium, $N['Media'])) { echo ' checked="checked"';} ?> />
160
+          <input type="checkbox" name="media<?=$i?>[]" id="<?=$Medium?>_<?=$N['ID']?>" value="<?=$Medium?>"<? if (in_array($Medium, $N['Media'])) { echo ' checked="checked"';} ?>>
188 161
           <label for="<?=$Medium?>_<?=$N['ID']?>"><?=$Medium?></label>
189 162
 <?  } ?>
190 163
         </td>
191 164
       </tr>
192
-      <tr>
193
-        <td class="label"><strong>Between the years</strong></td>
194
-        <td>
195
-          <input type="text" name="fromyear<?=$i?>" value="<?=$N['FromYear']?>" size="6" />
196
-          and
197
-          <input type="text" name="toyear<?=$i?>" value="<?=$N['ToYear']?>" size="6" />
198
-        </td>
199
-      </tr>
200 165
       <tr>
201 166
         <td class="label"><strong>Only new releases</strong></td>
202 167
         <td>
203
-          <input type="checkbox" name="newgroupsonly<?=$i?>" id="newgroupsonly_<?=$N['ID']?>"<? if ($N['NewGroupsOnly'] == '1') { echo ' checked="checked"';} ?> />
168
+          <input type="checkbox" name="newgroupsonly<?=$i?>" id="newgroupsonly_<?=$N['ID']?>"<? if ($N['NewGroupsOnly'] == '1') { echo ' checked="checked"';} ?>>
204 169
 <label for="newgroupsonly_<?=$N['ID']?>">Only notify for new releases, not new formats</label>
205 170
         </td>
206 171
       </tr>
207 172
       <tr>
208 173
         <td colspan="2" class="center">
209
-          <input type="submit" value="<?=($NewFilter ? 'Create filter' : 'Update filter')?>" />
174
+          <input type="submit" value="<?=($NewFilter ? 'Create filter' : 'Update filter')?>">
210 175
         </td>
211 176
       </tr>
212 177
     </table>

+ 2
- 48
sections/user/notify_handle.php View File

@@ -8,13 +8,8 @@ $FormID = '';
8 8
 $ArtistList = '';
9 9
 $TagList = '';
10 10
 $NotTagList = '';
11
-$ReleaseTypeList = '';
12 11
 $CategoryList = '';
13
-$FormatList = '';
14
-$EncodingList = '';
15 12
 $MediaList = '';
16
-$FromYear = 0;
17
-$ToYear = 0;
18 13
 $Users = '';
19 14
 $HasFilter = false;
20 15
 
@@ -76,31 +71,6 @@ if ($_POST['categories'.$FormID]) {
76 71
   $HasFilter = true;
77 72
 }
78 73
 
79
-if ($_POST['releasetypes'.$FormID]) {
80
-  $ReleaseTypeList = '|';
81
-  foreach ($_POST['releasetypes'.$FormID] as $ReleaseType) {
82
-    $ReleaseTypeList.=db_string(trim($ReleaseType)).'|';
83
-  }
84
-  $HasFilter = true;
85
-}
86
-
87
-if ($_POST['formats'.$FormID]) {
88
-  $FormatList = '|';
89
-  foreach ($_POST['formats'.$FormID] as $Format) {
90
-    $FormatList.=db_string(trim($Format)).'|';
91
-  }
92
-  $HasFilter = true;
93
-}
94
-
95
-
96
-if ($_POST['bitrates'.$FormID]) {
97
-  $EncodingList = '|';
98
-  foreach ($_POST['bitrates'.$FormID] as $Bitrate) {
99
-    $EncodingList.=db_string(trim($Bitrate)).'|';
100
-  }
101
-  $HasFilter = true;
102
-}
103
-
104 74
 if ($_POST['media'.$FormID]) {
105 75
   $MediaList = '|';
106 76
   foreach ($_POST['media'.$FormID] as $Medium) {
@@ -109,17 +79,6 @@ if ($_POST['media'.$FormID]) {
109 79
   $HasFilter = true;
110 80
 }
111 81
 
112
-if ($_POST['fromyear'.$FormID] && is_number($_POST['fromyear'.$FormID])) {
113
-  $FromYear = trim($_POST['fromyear'.$FormID]);
114
-  $HasFilter = true;
115
-  if ($_POST['toyear'.$FormID] && is_number($_POST['toyear'.$FormID])) {
116
-    $ToYear = trim($_POST['toyear'.$FormID]);
117
-  } else {
118
-    $ToYear = date('Y') + 3;
119
-  }
120
-}
121
-
122
-
123 82
 if ($_POST['users'.$FormID]) {
124 83
   $Usernames = explode(',', $_POST['users'.$FormID]);
125 84
   $EscapedUsernames = [];
@@ -167,22 +126,17 @@ if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
167 126
       NewGroupsOnly='$NewGroupsOnly',
168 127
       Tags='$TagList',
169 128
       NotTags='$NotTagList',
170
-      ReleaseTypes='$ReleaseTypeList',
171 129
       Categories='$CategoryList',
172
-      Formats='$FormatList',
173
-      Encodings='$EncodingList',
174 130
       Media='$MediaList',
175
-      FromYear='$FromYear',
176
-      ToYear='$ToYear',
177 131
       Users ='$Users'
178 132
     WHERE ID='".$_POST['id'.$FormID]."'
179 133
       AND UserID='$LoggedUser[ID]'");
180 134
 } else {
181 135
   $DB->query("
182 136
     INSERT INTO users_notify_filters
183
-      (UserID, Label, Artists, ExcludeVA, NewGroupsOnly, Tags, NotTags, ReleaseTypes, Categories, Formats, Encodings, Media, FromYear, ToYear, Users)
137
+      (UserID, Label, Artists, ExcludeVA, NewGroupsOnly, Tags, NotTags, Categories, Media, Users)
184 138
     VALUES
185
-      ('$LoggedUser[ID]','".db_string($_POST['label'.$FormID])."','$ArtistList','$ExcludeVA','$NewGroupsOnly','$TagList', '$NotTagList', '$ReleaseTypeList','$CategoryList','$FormatList','$EncodingList','$MediaList', '$FromYear', '$ToYear', '$Users')");
139
+      ('$LoggedUser[ID]','".db_string($_POST['label'.$FormID])."','$ArtistList','$ExcludeVA','$NewGroupsOnly','$TagList','$NotTagList','$CategoryList','$MediaList','$Users')");
186 140
 }
187 141
 
188 142
 $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);

Loading…
Cancel
Save