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
   }
82
   }
83
   if ($NewFilter && $NumFilters > 0) {
83
   if ($NewFilter && $NumFilters > 0) {
84
 ?>
84
 ?>
85
-  <br /><br />
85
+  <br><br>
86
   <h3>Create a new notification filter</h3>
86
   <h3>Create a new notification filter</h3>
87
 <?  } elseif ($NumFilters > 0) { ?>
87
 <?  } elseif ($NumFilters > 0) { ?>
88
   <h3>
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
     <?=display_str($N['Label'])?>
90
     <?=display_str($N['Label'])?>
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>
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
     <a data-toggle-target="#filter_<?=$N['ID']?>" class="brackets">Show</a>
92
     <a data-toggle-target="#filter_<?=$N['ID']?>" class="brackets">Show</a>
93
   </h3>
93
   </h3>
94
 <?  } ?>
94
 <?  } ?>
95
   <form class="box pad slight_margin <?=($NewFilter ? 'create_form' : 'edit_form')?>" id="<?=($NewFilter ? 'filter_form' : '')?>" name="notification" action="user.php" method="post">
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
 <?  if (!$NewFilter) { ?>
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
     <table <?=(!$NewFilter ? 'id="filter_'.$N['ID'].'" class="layout hidden"' : 'class="layout"')?>>
102
     <table <?=(!$NewFilter ? 'id="filter_'.$N['ID'].'" class="layout hidden"' : 'class="layout"')?>>
103
 <?  if ($NewFilter) { ?>
103
 <?  if ($NewFilter) { ?>
104
       <tr>
104
       <tr>
105
         <td class="label"><strong>Notification filter name</strong></td>
105
         <td class="label"><strong>Notification filter name</strong></td>
106
         <td>
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
           <p class="min_padding">A name for the notification filter set to tell different filters apart.</p>
108
           <p class="min_padding">A name for the notification filter set to tell different filters apart.</p>
109
         </td>
109
         </td>
110
       </tr>
110
       </tr>
118
         <td class="label"><strong>One of these artists</strong></td>
118
         <td class="label"><strong>One of these artists</strong></td>
119
         <td>
119
         <td>
120
           <textarea name="artists<?=$i?>" style="width: 100%;" rows="5"><?=display_str($N['Artists'])?></textarea>
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
           <label for="excludeva_<?=$N['ID']?>">Exclude Various Artists releases</label>
123
           <label for="excludeva_<?=$N['ID']?>">Exclude Various Artists releases</label>
124
         </td>
124
         </td>
125
       </tr>
125
       </tr>
134
         <td class="label"><strong>At least one of these tags</strong></td>
134
         <td class="label"><strong>At least one of these tags</strong></td>
135
         <td>
135
         <td>
136
           <textarea name="tags<?=$i?>" style="width: 100%;" rows="2"><?=display_str($N['Tags'])?></textarea>
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
         </td>
138
         </td>
139
       </tr>
139
       </tr>
140
       <tr>
140
       <tr>
141
         <td class="label"><strong>None of these tags</strong></td>
141
         <td class="label"><strong>None of these tags</strong></td>
142
         <td>
142
         <td>
143
           <textarea name="nottags<?=$i?>" style="width: 100%;" rows="2"><?=display_str($N['NotTags'])?></textarea>
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
         </td>
145
         </td>
146
       </tr>
146
       </tr>
147
       <tr>
147
       <tr>
148
         <td class="label"><strong>Only these categories</strong></td>
148
         <td class="label"><strong>Only these categories</strong></td>
149
         <td>
149
         <td>
150
 <?  foreach ($Categories as $Category) { ?>
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
           <label for="<?=$Category?>_<?=$N['ID']?>"><?=$Category?></label>
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
         </td>
154
         </td>
182
       </tr>
155
       </tr>
184
         <td class="label"><strong>Only these media</strong></td>
157
         <td class="label"><strong>Only these media</strong></td>
185
         <td>
158
         <td>
186
 <?  foreach ($Media as $Medium) { ?>
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
           <label for="<?=$Medium?>_<?=$N['ID']?>"><?=$Medium?></label>
161
           <label for="<?=$Medium?>_<?=$N['ID']?>"><?=$Medium?></label>
189
 <?  } ?>
162
 <?  } ?>
190
         </td>
163
         </td>
191
       </tr>
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
       <tr>
165
       <tr>
201
         <td class="label"><strong>Only new releases</strong></td>
166
         <td class="label"><strong>Only new releases</strong></td>
202
         <td>
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
 <label for="newgroupsonly_<?=$N['ID']?>">Only notify for new releases, not new formats</label>
169
 <label for="newgroupsonly_<?=$N['ID']?>">Only notify for new releases, not new formats</label>
205
         </td>
170
         </td>
206
       </tr>
171
       </tr>
207
       <tr>
172
       <tr>
208
         <td colspan="2" class="center">
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
         </td>
175
         </td>
211
       </tr>
176
       </tr>
212
     </table>
177
     </table>

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

8
 $ArtistList = '';
8
 $ArtistList = '';
9
 $TagList = '';
9
 $TagList = '';
10
 $NotTagList = '';
10
 $NotTagList = '';
11
-$ReleaseTypeList = '';
12
 $CategoryList = '';
11
 $CategoryList = '';
13
-$FormatList = '';
14
-$EncodingList = '';
15
 $MediaList = '';
12
 $MediaList = '';
16
-$FromYear = 0;
17
-$ToYear = 0;
18
 $Users = '';
13
 $Users = '';
19
 $HasFilter = false;
14
 $HasFilter = false;
20
 
15
 
76
   $HasFilter = true;
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
 if ($_POST['media'.$FormID]) {
74
 if ($_POST['media'.$FormID]) {
105
   $MediaList = '|';
75
   $MediaList = '|';
106
   foreach ($_POST['media'.$FormID] as $Medium) {
76
   foreach ($_POST['media'.$FormID] as $Medium) {
109
   $HasFilter = true;
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
 if ($_POST['users'.$FormID]) {
82
 if ($_POST['users'.$FormID]) {
124
   $Usernames = explode(',', $_POST['users'.$FormID]);
83
   $Usernames = explode(',', $_POST['users'.$FormID]);
125
   $EscapedUsernames = [];
84
   $EscapedUsernames = [];
167
       NewGroupsOnly='$NewGroupsOnly',
126
       NewGroupsOnly='$NewGroupsOnly',
168
       Tags='$TagList',
127
       Tags='$TagList',
169
       NotTags='$NotTagList',
128
       NotTags='$NotTagList',
170
-      ReleaseTypes='$ReleaseTypeList',
171
       Categories='$CategoryList',
129
       Categories='$CategoryList',
172
-      Formats='$FormatList',
173
-      Encodings='$EncodingList',
174
       Media='$MediaList',
130
       Media='$MediaList',
175
-      FromYear='$FromYear',
176
-      ToYear='$ToYear',
177
       Users ='$Users'
131
       Users ='$Users'
178
     WHERE ID='".$_POST['id'.$FormID]."'
132
     WHERE ID='".$_POST['id'.$FormID]."'
179
       AND UserID='$LoggedUser[ID]'");
133
       AND UserID='$LoggedUser[ID]'");
180
 } else {
134
 } else {
181
   $DB->query("
135
   $DB->query("
182
     INSERT INTO users_notify_filters
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
     VALUES
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
 $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
142
 $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);

Loading…
Cancel
Save