]> git.wh0rd.org - tt-rss.git/blame - classes/pref/filters.php
make pluginhost a singleton
[tt-rss.git] / classes / pref / filters.php
CommitLineData
8e17d663 1<?php
369dbc19 2class Pref_Filters extends Handler_Protected {
8e17d663 3
8484ce22 4 function csrf_ignore($method) {
6aff7845 5 $csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule",
a86ba0a6 6 "newaction", "savefilterorder");
8484ce22
AD
7
8 return array_search($method, $csrf_ignored) !== false;
9 }
10
a86ba0a6 11 function filtersortreset() {
d9c85e0f 12 $this->dbh->query("UPDATE ttrss_filters2
a86ba0a6
AD
13 SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
14 return;
15 }
16
17 function savefilterorder() {
18 $data = json_decode($_POST['payload'], true);
19
20 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
21 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
22
23 if (!is_array($data['items']))
24 $data['items'] = json_decode($data['items'], true);
25
26 $index = 0;
27
28 if (is_array($data) && is_array($data['items'])) {
29 foreach ($data['items'][0]['items'] as $item) {
30 $filter_id = (int) str_replace("FILTER:", "", $item['_reference']);
31
32 if ($filter_id > 0) {
33
d9c85e0f 34 $this->dbh->query("UPDATE ttrss_filters2 SET
a86ba0a6
AD
35 order_id = $index WHERE id = '$filter_id' AND
36 owner_uid = " .$_SESSION["uid"]);
37
38 ++$index;
39 }
40 }
41 }
42
43 return;
44 }
45
46
4e02f582
AD
47 function testFilter() {
48 $filter = array();
8e17d663 49
4e02f582
AD
50 $filter["enabled"] = true;
51 $filter["match_any_rule"] = sql_bool_to_bool(
d9c85e0f 52 checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["match_any_rule"])));
a3a896a1 53 $filter["inverse"] = sql_bool_to_bool(
d9c85e0f 54 checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["inverse"])));
a3a896a1 55
4e02f582 56 $filter["rules"] = array();
8e17d663 57
d9c85e0f 58 $result = $this->dbh->query("SELECT id,name FROM ttrss_filter_types");
8e17d663 59
4e02f582 60 $filter_types = array();
d9c85e0f 61 while ($line = $this->dbh->fetch_assoc($result)) {
4e02f582
AD
62 $filter_types[$line["id"]] = $line["name"];
63 }
8e17d663 64
4e02f582
AD
65 $rctr = 0;
66 foreach ($_REQUEST["rule"] AS $r) {
67 $rule = json_decode($r, true);
8e17d663 68
4e02f582
AD
69 if ($rule && $rctr < 5) {
70 $rule["type"] = $filter_types[$rule["filter_type"]];
71 unset($rule["filter_type"]);
8e17d663 72
4e02f582
AD
73 if (strpos($rule["feed_id"], "CAT:") === 0) {
74 $rule["cat_id"] = (int) substr($rule["feed_id"], 4);
75 unset($rule["feed_id"]);
76 }
8e17d663 77
4e02f582 78 array_push($filter["rules"], $rule);
8e17d663 79
4e02f582
AD
80 ++$rctr;
81 } else {
82 break;
83 }
84 }
8e17d663 85
a42c55f0 86 $feed_title = getFeedTitle($feed);
8e17d663 87
a42c55f0 88 $qfh_ret = queryFeedHeadlines(-4, 30, "", false, false, false,
ca5d9be4 89 "date_entered DESC", 0, $_SESSION["uid"], $filter);
8e17d663 90
4e02f582 91 $result = $qfh_ret[0];
8e17d663 92
4e02f582
AD
93 $articles = array();
94 $found = 0;
8e17d663 95
4e02f582 96 print __("Articles matching this filter:");
8e17d663 97
4e02f582
AD
98 print "<div class=\"filterTestHolder\">";
99 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
8e17d663 100
d9c85e0f 101 while ($line = $this->dbh->fetch_assoc($result)) {
8e17d663 102
4e02f582 103 $entry_timestamp = strtotime($line["updated"]);
a42c55f0 104 $entry_tags = get_article_tags($line["id"], $_SESSION["uid"]);
8e17d663 105
4e02f582
AD
106 $content_preview = truncate_string(
107 strip_tags($line["content_preview"]), 100, '...');
56fbb82c 108
4e02f582
AD
109 if ($line["feed_title"])
110 $feed_title = $line["feed_title"];
56fbb82c 111
4e02f582 112 print "<tr>";
56fbb82c 113
4e02f582
AD
114 print "<td width='5%' align='center'><input
115 dojoType=\"dijit.form.CheckBox\" checked=\"1\"
116 disabled=\"1\" type=\"checkbox\"></td>";
117 print "<td>";
56fbb82c 118
4e02f582
AD
119 print $line["title"];
120 print "&nbsp;(";
121 print "<b>" . $feed_title . "</b>";
122 print "):&nbsp;";
123 print "<span class=\"insensitive\">" . $content_preview . "</span>";
124 print " " . mb_substr($line["date_entered"], 0, 16);
56fbb82c 125
4e02f582 126 print "</td></tr>";
56fbb82c 127
4e02f582
AD
128 $found++;
129 }
8e17d663 130
4e02f582
AD
131 if ($found == 0) {
132 print "<tr><td align='center'>" .
5cb17306
AD
133 __("No recent articles matching this filter have been found.");
134
135 print "</td></tr><tr><td class='insensitive' align='center'>";
136
137 print __("Complex expressions might not give results while testing due to issues with database server regexp implementation.");
138
139 print "</td></tr>";
140
8e17d663
AD
141 }
142
4e02f582
AD
143 print "</table></div>";
144
145 print "<div style='text-align : center'>";
146 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('filterTestDlg').hide()\">".
147 __('Close this window')."</button>";
8e17d663
AD
148 print "</div>";
149
4e02f582
AD
150 }
151
8e17d663
AD
152
153 function getfiltertree() {
154 $root = array();
155 $root['id'] = 'root';
156 $root['name'] = __('Filters');
157 $root['items'] = array();
158
69c6e94d
AD
159 $filter_search = $_SESSION["prefs_filter_search"];
160
d9c85e0f 161 $result = $this->dbh->query("SELECT *,
84d9750e
AD
162 (SELECT action_param FROM ttrss_filters2_actions
163 WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS action_param,
6aff7845
AD
164 (SELECT action_id FROM ttrss_filters2_actions
165 WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS action_id,
37f78940
AD
166 (SELECT description FROM ttrss_filter_actions
167 WHERE id = (SELECT action_id FROM ttrss_filters2_actions
168 WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1)) AS action_name,
6aff7845
AD
169 (SELECT reg_exp FROM ttrss_filters2_rules
170 WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS reg_exp
171 FROM ttrss_filters2 WHERE
f0419320 172 owner_uid = ".$_SESSION["uid"]." ORDER BY order_id, title");
8e17d663 173
69c6e94d 174
37f78940
AD
175 $action_id = -1;
176 $folder = array();
177 $folder['items'] = array();
178
d9c85e0f 179 while ($line = $this->dbh->fetch_assoc($result)) {
8e17d663 180
da46d21e 181 /* if ($action_id != $line["action_id"]) {
37f78940 182 if (count($folder['items']) > 0) {
37f78940
AD
183 array_push($root['items'], $folder);
184 }
e8b70387 185
37f78940 186 $folder = array();
e8b70387 187 $folder['id'] = $line["action_id"];
7b28a986 188 $folder['name'] = __($line["action_name"]);
37f78940
AD
189 $folder['items'] = array();
190 $action_id = $line["action_id"];
da46d21e 191 } */
37f78940 192
6aff7845 193 $name = $this->getFilterName($line["id"]);
8e17d663 194
69c6e94d
AD
195 $match_ok = false;
196 if ($filter_search) {
d9c85e0f 197 $rules_result = $this->dbh->query(
69c6e94d
AD
198 "SELECT reg_exp FROM ttrss_filters2_rules WHERE filter_id = ".$line["id"]);
199
d9c85e0f 200 while ($rule_line = $this->dbh->fetch_assoc($rules_result)) {
69c6e94d
AD
201 if (mb_strpos($rule_line['reg_exp'], $filter_search) !== false) {
202 $match_ok = true;
203 break;
204 }
205 }
206 }
207
84d9750e 208 if ($line['action_id'] == 7) {
d9c85e0f
AD
209 $label_result = $this->dbh->query("SELECT fg_color, bg_color
210 FROM ttrss_labels2 WHERE caption = '".$this->dbh->escape_string($line['action_param'])."' AND
84d9750e
AD
211 owner_uid = " . $_SESSION["uid"]);
212
d9c85e0f
AD
213 if ($this->dbh->num_rows($label_result) > 0) {
214 $fg_color = $this->dbh->fetch_result($label_result, 0, "fg_color");
215 $bg_color = $this->dbh->fetch_result($label_result, 0, "bg_color");
84d9750e 216
da46d21e 217 $name[1] = "<span class=\"labelColorIndicator\" id=\"label-editor-indicator\" style='color : $fg_color; background-color : $bg_color; margin-right : 4px'>&alpha;</span>" . $name[1];
84d9750e
AD
218 }
219 }
220
6aff7845
AD
221 $filter = array();
222 $filter['id'] = 'FILTER:' . $line['id'];
223 $filter['bare_id'] = $line['id'];
224 $filter['name'] = $name[0];
225 $filter['param'] = $name[1];
226 $filter['checkbox'] = false;
c2ee5846 227 $filter['enabled'] = sql_bool_to_bool($line["enabled"]);
8e17d663 228
69c6e94d
AD
229 if (!$filter_search || $match_ok) {
230 array_push($folder['items'], $filter);
231 }
8e17d663
AD
232 }
233
da46d21e 234 /* if (count($folder['items']) > 0) {
e8b70387 235 array_push($root['items'], $folder);
da46d21e
AD
236 } */
237
238 $root['items'] = $folder['items'];
e8b70387 239
8e17d663
AD
240 $fl = array();
241 $fl['identifier'] = 'id';
242 $fl['label'] = 'name';
243 $fl['items'] = array($root);
244
245 print json_encode($fl);
246 return;
247 }
248
249 function edit() {
250
d9c85e0f 251 $filter_id = $this->dbh->escape_string($_REQUEST["id"]);
8e17d663 252
d9c85e0f 253 $result = $this->dbh->query(
6aff7845 254 "SELECT * FROM ttrss_filters2 WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
8e17d663 255
d9c85e0f
AD
256 $enabled = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "enabled"));
257 $match_any_rule = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "match_any_rule"));
258 $inverse = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "inverse"));
259 $title = htmlspecialchars($this->dbh->fetch_result($result, 0, "title"));
8e17d663
AD
260
261 print "<form id=\"filter_edit_form\" onsubmit='return false'>";
262
263 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
264 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$filter_id\">";
265 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
b69a09ea 266 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
8e17d663 267
18ad09af
AD
268 print "<div class=\"dlgSec\">".__("Caption")."</div>";
269
442bca27 270 print "<input required=\"true\" dojoType=\"dijit.form.ValidationTextBox\" style=\"width : 20em;\" name=\"title\" value=\"$title\">";
18ad09af
AD
271
272 print "</div>";
273
8e17d663
AD
274 print "<div class=\"dlgSec\">".__("Match")."</div>";
275
6aff7845 276 print "<div dojoType=\"dijit.Toolbar\">";
8e17d663 277
6aff7845
AD
278 print "<div dojoType=\"dijit.form.DropDownButton\">".
279 "<span>" . __('Select')."</span>";
280 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
281 print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\"
282 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
283 print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\"
284 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
285 print "</div></div>";
8e17d663 286
6aff7845
AD
287 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addRule()\">".
288 __('Add')."</button> ";
8e17d663 289
6aff7845
AD
290 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">".
291 __('Delete')."</button> ";
8e17d663 292
6aff7845 293 print "</div>";
8e17d663 294
6aff7845 295 print "<ul id='filterDlg_Matches'>";
8e17d663 296
d9c85e0f 297 $rules_result = $this->dbh->query("SELECT * FROM ttrss_filters2_rules
56b2a409 298 WHERE filter_id = '$filter_id' ORDER BY reg_exp, id");
8e17d663 299
d9c85e0f 300 while ($line = $this->dbh->fetch_assoc($rules_result)) {
5451903c 301 if (sql_bool_to_bool($line["cat_filter"])) {
6aff7845 302 $line["feed_id"] = "CAT:" . (int)$line["cat_id"];
6aff7845 303 }
8e17d663 304
4e02f582
AD
305 unset($line["cat_filter"]);
306 unset($line["cat_id"]);
307 unset($line["filter_id"]);
308 unset($line["id"]);
a3a896a1 309 if (!sql_bool_to_bool($line["inverse"])) unset($line["inverse"]);
4e02f582 310
6aff7845 311 $data = htmlspecialchars(json_encode($line));
8e17d663 312
04e41840 313 print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='toggleSelectListRow2(this)'>".
6aff7845
AD
314 "<span onclick=\"dijit.byId('filterEditDlg').editRule(this)\">".$this->getRuleName($line)."</span>".
315 "<input type='hidden' name='rule[]' value=\"$data\"/></li>";
316 }
ba975b2e 317
6aff7845 318 print "</ul>";
ba975b2e 319
8e17d663
AD
320 print "</div>";
321
6aff7845 322 print "<div class=\"dlgSec\">".__("Apply actions")."</div>";
8e17d663 323
6aff7845 324 print "<div dojoType=\"dijit.Toolbar\">";
8e17d663 325
6aff7845
AD
326 print "<div dojoType=\"dijit.form.DropDownButton\">".
327 "<span>" . __('Select')."</span>";
328 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
329 print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\"
330 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
331 print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\"
332 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
333 print "</div></div>";
8e17d663 334
6aff7845
AD
335 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addAction()\">".
336 __('Add')."</button> ";
8e17d663 337
6aff7845
AD
338 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">".
339 __('Delete')."</button> ";
8e17d663 340
6aff7845 341 print "</div>";
8e17d663 342
6aff7845 343 print "<ul id='filterDlg_Actions'>";
8e17d663 344
d9c85e0f 345 $actions_result = $this->dbh->query("SELECT * FROM ttrss_filters2_actions
6aff7845 346 WHERE filter_id = '$filter_id' ORDER BY id");
8e17d663 347
d9c85e0f 348 while ($line = $this->dbh->fetch_assoc($actions_result)) {
6aff7845 349 $line["action_param_label"] = $line["action_param"];
4e02f582
AD
350
351 unset($line["filter_id"]);
352 unset($line["id"]);
353
6aff7845 354 $data = htmlspecialchars(json_encode($line));
8e17d663 355
04e41840 356 print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='toggleSelectListRow2(this)'>".
6aff7845
AD
357 "<span onclick=\"dijit.byId('filterEditDlg').editAction(this)\">".$this->getActionName($line)."</span>".
358 "<input type='hidden' name='action[]' value=\"$data\"/></li>";
359 }
8e17d663 360
6aff7845 361 print "</ul>";
8e17d663
AD
362
363 print "</div>";
364
8e17d663
AD
365 if ($enabled) {
366 $checked = "checked=\"1\"";
367 } else {
368 $checked = "";
369 }
370
371 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked>
6aff7845 372 <label for=\"enabled\">".__('Enabled')."</label>";
8e17d663 373
6aff7845 374 if ($match_any_rule) {
8e17d663
AD
375 $checked = "checked=\"1\"";
376 } else {
377 $checked = "";
378 }
379
6aff7845
AD
380 print "<br/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"match_any_rule\" id=\"match_any_rule\" $checked>
381 <label for=\"match_any_rule\">".__('Match any rule')."</label>";
8e17d663 382
a3a896a1
AD
383 if ($inverse) {
384 $checked = "checked=\"1\"";
385 } else {
386 $checked = "";
387 }
388
389 print "<br/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
390 <label for=\"inverse\">".__('Inverse matching')."</label>";
391
6aff7845 392 print "<p/>";
8e17d663
AD
393
394 print "<div class=\"dlgButtons\">";
395
396 print "<div style=\"float : left\">";
397 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').removeFilter()\">".
398 __('Remove')."</button>";
399 print "</div>";
400
4e02f582
AD
401 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
402 __('Test')."</button> ";
8e17d663
AD
403
404 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
405 __('Save')."</button> ";
406
407 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
408 __('Cancel')."</button>";
409
410 print "</div>";
411 }
412
6aff7845
AD
413 private function getRuleName($rule) {
414 if (!$rule) $rule = json_decode($_REQUEST["rule"], true);
8e17d663 415
6aff7845 416 $feed_id = $rule["feed_id"];
8e17d663 417
4c9d0490 418 if (strpos($feed_id, "CAT:") === 0) {
6aff7845 419 $feed_id = (int) substr($feed_id, 4);
a42c55f0 420 $feed = getCategoryTitle($feed_id);
8e17d663 421 } else {
4c9d0490 422 $feed_id = (int) $feed_id;
6aff7845
AD
423
424 if ($rule["feed_id"])
a42c55f0 425 $feed = getFeedTitle((int)$rule["feed_id"]);
6aff7845
AD
426 else
427 $feed = __("All feeds");
8e17d663
AD
428 }
429
d9c85e0f 430 $result = $this->dbh->query("SELECT description FROM ttrss_filter_types
6aff7845 431 WHERE id = ".(int)$rule["filter_type"]);
d9c85e0f 432 $filter_type = $this->dbh->fetch_result($result, 0, "description");
4c9d0490 433
a3a896a1
AD
434 return T_sprintf("%s on %s in %s %s", strip_tags($rule["reg_exp"]),
435 $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "");
6aff7845 436 }
ba975b2e 437
6aff7845
AD
438 function printRuleName() {
439 print $this->getRuleName(json_decode($_REQUEST["rule"], true));
440 }
8e17d663 441
6aff7845 442 private function getActionName($action) {
d9c85e0f 443 $result = $this->dbh->query("SELECT description FROM
6aff7845 444 ttrss_filter_actions WHERE id = " .(int)$action["action_id"]);
8e17d663 445
d9c85e0f 446 $title = __($this->dbh->fetch_result($result, 0, "description"));
8e17d663 447
6aff7845
AD
448 if ($action["action_id"] == 4 || $action["action_id"] == 6 ||
449 $action["action_id"] == 7)
450 $title .= ": " . $action["action_param"];
8e17d663 451
6aff7845
AD
452 return $title;
453 }
8e17d663 454
6aff7845
AD
455 function printActionName() {
456 print $this->getActionName(json_decode($_REQUEST["action"], true));
457 }
458
459 function editSave() {
4e02f582
AD
460 if ($_REQUEST["savemode"] && $_REQUEST["savemode"] == "test") {
461 return $this->testFilter();
462 }
6aff7845
AD
463
464# print_r($_REQUEST);
465
d9c85e0f
AD
466 $filter_id = $this->dbh->escape_string($_REQUEST["id"]);
467 $enabled = checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["enabled"]));
468 $match_any_rule = checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["match_any_rule"]));
469 $inverse = checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["inverse"]));
470 $title = $this->dbh->escape_string($_REQUEST["title"]);
6aff7845 471
d9c85e0f 472 $result = $this->dbh->query("UPDATE ttrss_filters2 SET enabled = $enabled,
a3a896a1 473 match_any_rule = $match_any_rule,
18ad09af
AD
474 inverse = $inverse,
475 title = '$title'
6aff7845
AD
476 WHERE id = '$filter_id'
477 AND owner_uid = ". $_SESSION["uid"]);
478
479 $this->saveRulesAndActions($filter_id);
8e17d663 480
8e17d663
AD
481 }
482
483 function remove() {
484
d9c85e0f 485 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
8e17d663
AD
486
487 foreach ($ids as $id) {
d9c85e0f 488 $this->dbh->query("DELETE FROM ttrss_filters2 WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
8e17d663
AD
489 }
490 }
491
6aff7845 492 private function saveRulesAndActions($filter_id) {
8e17d663 493
d9c85e0f
AD
494 $this->dbh->query("DELETE FROM ttrss_filters2_rules WHERE filter_id = '$filter_id'");
495 $this->dbh->query("DELETE FROM ttrss_filters2_actions WHERE filter_id = '$filter_id'");
8e17d663 496
6aff7845
AD
497 if ($filter_id) {
498 /* create rules */
8e17d663 499
6aff7845
AD
500 $rules = array();
501 $actions = array();
8e17d663 502
6aff7845
AD
503 foreach ($_REQUEST["rule"] as $rule) {
504 $rule = json_decode($rule, true);
505 unset($rule["id"]);
8e17d663 506
6aff7845
AD
507 if (array_search($rule, $rules) === false) {
508 array_push($rules, $rule);
509 }
510 }
4c9d0490 511
6aff7845
AD
512 foreach ($_REQUEST["action"] as $action) {
513 $action = json_decode($action, true);
514 unset($action["id"]);
ba975b2e 515
6aff7845
AD
516 if (array_search($action, $actions) === false) {
517 array_push($actions, $action);
518 }
519 }
8e17d663 520
6aff7845
AD
521 foreach ($rules as $rule) {
522 if ($rule) {
8e17d663 523
d9c85e0f 524 $reg_exp = strip_tags($this->dbh->escape_string(trim($rule["reg_exp"])));
a3a896a1
AD
525 $inverse = isset($rule["inverse"]) ? "true" : "false";
526
d9c85e0f
AD
527 $filter_type = (int) $this->dbh->escape_string(trim($rule["filter_type"]));
528 $feed_id = $this->dbh->escape_string(trim($rule["feed_id"]));
6aff7845
AD
529
530 if (strpos($feed_id, "CAT:") === 0) {
5451903c 531
6aff7845
AD
532 $cat_filter = bool_to_sql_bool(true);
533 $cat_id = (int) substr($feed_id, 4);
534 $feed_id = "NULL";
8e17d663 535
6aff7845
AD
536 if (!$cat_id) $cat_id = "NULL"; // Uncategorized
537 } else {
538 $cat_filter = bool_to_sql_bool(false);
539 $feed_id = (int) $feed_id;
540 $cat_id = "NULL";
541
542 if (!$feed_id) $feed_id = "NULL"; // Uncategorized
543 }
544
545 $query = "INSERT INTO ttrss_filters2_rules
a3a896a1
AD
546 (filter_id, reg_exp,filter_type,feed_id,cat_id,cat_filter,inverse) VALUES
547 ('$filter_id', '$reg_exp', '$filter_type', $feed_id, $cat_id, $cat_filter, $inverse)";
6aff7845 548
d9c85e0f 549 $this->dbh->query($query);
6aff7845 550 }
8e17d663
AD
551 }
552
6aff7845
AD
553 foreach ($actions as $action) {
554 if ($action) {
555
d9c85e0f
AD
556 $action_id = (int) $this->dbh->escape_string($action["action_id"]);
557 $action_param = $this->dbh->escape_string($action["action_param"]);
558 $action_param_label = $this->dbh->escape_string($action["action_param_label"]);
6aff7845
AD
559
560 if ($action_id == 7) {
561 $action_param = $action_param_label;
562 }
8e17d663 563
6aff7845
AD
564 if ($action_id == 6) {
565 $action_param = (int) str_replace("+", "", $action_param);
566 }
8e17d663 567
6aff7845
AD
568 $query = "INSERT INTO ttrss_filters2_actions
569 (filter_id, action_id, action_param) VALUES
570 ('$filter_id', '$action_id', '$action_param')";
8e17d663 571
d9c85e0f 572 $this->dbh->query($query);
6aff7845
AD
573 }
574 }
8e17d663 575 }
6aff7845
AD
576
577
578 }
579
580 function add() {
4e02f582
AD
581 if ($_REQUEST["savemode"] && $_REQUEST["savemode"] == "test") {
582 return $this->testFilter();
583 }
584
6aff7845
AD
585# print_r($_REQUEST);
586
587 $enabled = checkbox_to_sql_bool($_REQUEST["enabled"]);
588 $match_any_rule = checkbox_to_sql_bool($_REQUEST["match_any_rule"]);
d9c85e0f 589 $title = $this->dbh->escape_string($_REQUEST["title"]);
6aff7845 590
d9c85e0f 591 $this->dbh->query("BEGIN");
6aff7845
AD
592
593 /* create base filter */
594
d9c85e0f 595 $result = $this->dbh->query("INSERT INTO ttrss_filters2
18ad09af
AD
596 (owner_uid, match_any_rule, enabled, title) VALUES
597 (".$_SESSION["uid"].",$match_any_rule,$enabled, '$title')");
6aff7845 598
d9c85e0f 599 $result = $this->dbh->query("SELECT MAX(id) AS id FROM ttrss_filters2
6aff7845
AD
600 WHERE owner_uid = ".$_SESSION["uid"]);
601
d9c85e0f 602 $filter_id = $this->dbh->fetch_result($result, 0, "id");
6aff7845
AD
603
604 $this->saveRulesAndActions($filter_id);
605
d9c85e0f 606 $this->dbh->query("COMMIT");
8e17d663
AD
607 }
608
609 function index() {
610
d9c85e0f 611 $sort = $this->dbh->escape_string($_REQUEST["sort"]);
8e17d663
AD
612
613 if (!$sort || $sort == "undefined") {
614 $sort = "reg_exp";
615 }
616
d9c85e0f 617 $filter_search = $this->dbh->escape_string($_REQUEST["search"]);
8e17d663
AD
618
619 if (array_key_exists("search", $_REQUEST)) {
620 $_SESSION["prefs_filter_search"] = $filter_search;
621 } else {
622 $filter_search = $_SESSION["prefs_filter_search"];
623 }
624
625 print "<div id=\"pref-filter-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
626 print "<div id=\"pref-filter-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
627 print "<div id=\"pref-filter-toolbar\" dojoType=\"dijit.Toolbar\">";
628
d9c85e0f 629 $filter_search = $this->dbh->escape_string($_REQUEST["search"]);
310fa2dd
AD
630
631 if (array_key_exists("search", $_REQUEST)) {
632 $_SESSION["prefs_filter_search"] = $filter_search;
633 } else {
634 $filter_search = $_SESSION["prefs_filter_search"];
635 }
636
637 print "<div style='float : right; padding-right : 4px;'>
638 <input dojoType=\"dijit.form.TextBox\" id=\"filter_search\" size=\"20\" type=\"search\"
639 value=\"$filter_search\">
640 <button dojoType=\"dijit.form.Button\" onclick=\"updateFilterList()\">".
641 __('Search')."</button>
642 </div>";
643
8e17d663
AD
644 print "<div dojoType=\"dijit.form.DropDownButton\">".
645 "<span>" . __('Select')."</span>";
646 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
647 print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\"
648 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
649 print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\"
650 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
651 print "</div></div>";
652
653 print "<button dojoType=\"dijit.form.Button\" onclick=\"return quickAddFilter()\">".
654 __('Create filter')."</button> ";
655
6aff7845
AD
656 print "<button dojoType=\"dijit.form.Button\" onclick=\"return joinSelectedFilters()\">".
657 __('Combine')."</button> ";
658
8e17d663
AD
659 print "<button dojoType=\"dijit.form.Button\" onclick=\"return editSelectedFilter()\">".
660 __('Edit')."</button> ";
661
a86ba0a6
AD
662 print "<button dojoType=\"dijit.form.Button\" onclick=\"return resetFilterOrder()\">".
663 __('Reset sort order')."</button> ";
664
665
8e17d663
AD
666 print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">".
667 __('Remove')."</button> ";
668
669 if (defined('_ENABLE_FEED_DEBUGGING')) {
670 print "<button dojoType=\"dijit.form.Button\" onclick=\"rescore_all_feeds()\">".
671 __('Rescore articles')."</button> ";
672 }
673
674 print "</div>"; # toolbar
675 print "</div>"; # toolbar-frame
676 print "<div id=\"pref-filter-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
677
678 print "<div id=\"filterlistLoading\">
679 <img src='images/indicator_tiny.gif'>".
680 __("Loading, please wait...")."</div>";
681
a86ba0a6 682 print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\"
8e17d663
AD
683 url=\"backend.php?op=pref-filters&method=getfiltertree\">
684 </div>
685 <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\"
a86ba0a6 686 query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Filters\"
8e17d663
AD
687 childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">
688 </div>
689 <div dojoType=\"fox.PrefFilterTree\" id=\"filterTree\"
a86ba0a6
AD
690 dndController=\"dijit.tree.dndSource\"
691 betweenThreshold=\"5\"
8e17d663
AD
692 model=\"filterModel\" openOnClick=\"true\">
693 <script type=\"dojo/method\" event=\"onLoad\" args=\"item\">
694 Element.hide(\"filterlistLoading\");
695 </script>
696 <script type=\"dojo/method\" event=\"onClick\" args=\"item\">
697 var id = String(item.id);
698 var bare_id = id.substr(id.indexOf(':')+1);
699
700 if (id.match('FILTER:')) {
701 editFilter(bare_id);
702 }
703 </script>
704
705 </div>";
706
707 print "</div>"; #pane
6065f3ad 708
1ffe3391 709 PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
6065f3ad
AD
710 "hook_prefs_tab", "prefFilters");
711
8e17d663
AD
712 print "</div>"; #container
713
714 }
6aff7845
AD
715
716 function newfilter() {
717
718 print "<form name='filter_new_form' id='filter_new_form'>";
719
6aff7845
AD
720 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
721 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
722 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
723
18ad09af
AD
724 print "<div class=\"dlgSec\">".__("Caption")."</div>";
725
442bca27 726 print "<input required=\"true\" dojoType=\"dijit.form.ValidationTextBox\" style=\"width : 20em;\" name=\"title\" value=\"\">";
18ad09af 727
6aff7845
AD
728 print "<div class=\"dlgSec\">".__("Match")."</div>";
729
730 print "<div dojoType=\"dijit.Toolbar\">";
731
732 print "<div dojoType=\"dijit.form.DropDownButton\">".
733 "<span>" . __('Select')."</span>";
734 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
735 print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\"
736 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
737 print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\"
738 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
739 print "</div></div>";
740
741 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addRule()\">".
742 __('Add')."</button> ";
743
744 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">".
745 __('Delete')."</button> ";
746
747 print "</div>";
748
749 print "<ul id='filterDlg_Matches'>";
750# print "<li>No rules</li>";
751 print "</ul>";
752
753 print "</div>";
754
755 print "<div class=\"dlgSec\">".__("Apply actions")."</div>";
756
757 print "<div dojoType=\"dijit.Toolbar\">";
758
759 print "<div dojoType=\"dijit.form.DropDownButton\">".
760 "<span>" . __('Select')."</span>";
761 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
762 print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\"
763 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
764 print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\"
765 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
766 print "</div></div>";
767
768 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addAction()\">".
769 __('Add')."</button> ";
770
771 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">".
772 __('Delete')."</button> ";
773
774 print "</div>";
775
776 print "<ul id='filterDlg_Actions'>";
777# print "<li>No actions</li>";
778 print "</ul>";
779
780/* print "<div class=\"dlgSec\">".__("Options")."</div>";
781 print "<div class=\"dlgSecCont\">"; */
782
783 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
784 <label for=\"enabled\">".__('Enabled')."</label>";
785
786 print "<br/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"match_any_rule\" id=\"match_any_rule\">
787 <label for=\"match_any_rule\">".__('Match any rule')."</label>";
788
a3a896a1
AD
789 print "<br/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
790 <label for=\"inverse\">".__('Inverse matching')."</label>";
6aff7845
AD
791
792// print "</div>";
793
794 print "<div class=\"dlgButtons\">";
795
4e02f582
AD
796 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
797 __('Test')."</button> ";
6aff7845
AD
798
799 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
800 __('Create')."</button> ";
801
802 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
803 __('Cancel')."</button>";
804
805 print "</div>";
806
807 }
808
809 function newrule() {
810 $rule = json_decode($_REQUEST["rule"], true);
811
812 if ($rule) {
813 $reg_exp = htmlspecialchars($rule["reg_exp"]);
814 $filter_type = $rule["filter_type"];
815 $feed_id = $rule["feed_id"];
a3a896a1 816 $inverse_checked = isset($rule["inverse"]) ? "checked" : "";
6aff7845
AD
817 } else {
818 $reg_exp = "";
819 $filter_type = 1;
820 $feed_id = 0;
a3a896a1 821 $inverse_checked = "";
6aff7845
AD
822 }
823
824 if (strpos($feed_id, "CAT:") === 0) {
825 $feed_id = substr($feed_id, 4);
826 $cat_filter = true;
827 } else {
828 $cat_filter = false;
829 }
830
831
832 print "<form name='filter_new_rule_form' id='filter_new_rule_form'>";
833
d9c85e0f 834 $result = $this->dbh->query("SELECT id,description
37f78940 835 FROM ttrss_filter_types WHERE id != 5 ORDER BY description");
6aff7845
AD
836
837 $filter_types = array();
838
d9c85e0f 839 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
840 $filter_types[$line["id"]] = __($line["description"]);
841 }
842
843 print "<div class=\"dlgSec\">".__("Match")."</div>";
844
845 print "<div class=\"dlgSecCont\">";
846
847 print "<input dojoType=\"dijit.form.ValidationTextBox\"
848 required=\"true\" id=\"filterDlg_regExp\"
ff34bac2 849 style=\"font-size : 16px; width : 20em;\"
6aff7845
AD
850 name=\"reg_exp\" value=\"$reg_exp\"/>";
851
ec1f8a3d
AD
852 print "<hr/>";
853 print "<input id=\"filterDlg_inverse\" dojoType=\"dijit.form.CheckBox\"
854 name=\"inverse\" $inverse_checked/>";
855 print "<label for=\"filterDlg_inverse\">".__("Inverse regular expression matching")."</label>";
856
6aff7845
AD
857 print "<hr/>" . __("on field") . " ";
858 print_select_hash("filter_type", $filter_type, $filter_types,
859 'dojoType="dijit.form.Select"');
860
861 print "<hr/>";
862
863 print __("in") . " ";
864
865 print "<span id='filterDlg_feeds'>";
a42c55f0 866 print_feed_select("feed_id",
6aff7845
AD
867 $cat_filter ? "CAT:$feed_id" : $feed_id,
868 'dojoType="dijit.form.FilteringSelect"');
869 print "</span>";
870
871 print "</div>";
872
873 print "<div class=\"dlgButtons\">";
874
875 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewRuleDlg').execute()\">".
876 ($rule ? __("Save rule") : __('Add rule'))."</button> ";
877
878 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewRuleDlg').hide()\">".
879 __('Cancel')."</button>";
880
881 print "</div>";
882
883 print "</form>";
884 }
885
886 function newaction() {
887 $action = json_decode($_REQUEST["action"], true);
888
889 if ($action) {
d9c85e0f 890 $action_param = $this->dbh->escape_string($action["action_param"]);
6aff7845
AD
891 $action_id = (int)$action["action_id"];
892 } else {
893 $action_param = "";
894 $action_id = 0;
895 }
896
897 print "<form name='filter_new_action_form' id='filter_new_action_form'>";
898
899 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
900
901 print "<div class=\"dlgSecCont\">";
902
903 print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
904 onchange=\"filterDlgCheckAction(this)\">";
905
d9c85e0f 906 $result = $this->dbh->query("SELECT id,description FROM ttrss_filter_actions
6aff7845
AD
907 ORDER BY name");
908
d9c85e0f 909 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
910 $is_selected = ($line["id"] == $action_id) ? "selected='1'" : "";
911 printf("<option $is_selected value='%d'>%s</option>", $line["id"], __($line["description"]));
912 }
913
914 print "</select>";
915
916 $param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6) ?
917 "" : "display : none";
918
919 $param_hidden = ($action_id == 4 || $action_id == 6) ?
920 "" : "display : none";
921
922 $label_param_hidden = ($action_id == 7) ? "" : "display : none";
923
924 print "<span id=\"filterDlg_paramBox\" style=\"$param_box_hidden\">";
925 print " " . __("with parameters:") . " ";
926 print "<input dojoType=\"dijit.form.TextBox\"
927 id=\"filterDlg_actionParam\" style=\"$param_hidden\"
928 name=\"action_param\" value=\"$action_param\">";
929
a42c55f0 930 print_label_select("action_param_label", $action_param,
6aff7845
AD
931 "id=\"filterDlg_actionParamLabel\" style=\"$label_param_hidden\"
932 dojoType=\"dijit.form.Select\"");
933
934 print "</span>";
935
936 print "&nbsp;"; // tiny layout hack
937
938 print "</div>";
939
940 print "<div class=\"dlgButtons\">";
941
942 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewActionDlg').execute()\">".
943 ($action ? __("Save action") : __('Add action'))."</button> ";
944
945 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewActionDlg').hide()\">".
946 __('Cancel')."</button>";
947
948 print "</div>";
949
950 print "</form>";
951 }
952
953 private function getFilterName($id) {
18ad09af 954
d9c85e0f 955 $result = $this->dbh->query(
1a293f10
AD
956 "SELECT title,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
957 FROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r
958 ON (r.filter_id = f.id)
959 LEFT JOIN ttrss_filters2_actions AS a
960 ON (a.filter_id = f.id) WHERE f.id = '$id' GROUP BY f.title");
18ad09af 961
d9c85e0f
AD
962 $title = $this->dbh->fetch_result($result, 0, "title");
963 $num_rules = $this->dbh->fetch_result($result, 0, "num_rules");
964 $num_actions = $this->dbh->fetch_result($result, 0, "num_actions");
18ad09af 965
1a293f10 966 if (!$title) $title = __("[No caption]");
18ad09af 967
1a293f10 968 $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", $num_rules), $title, $num_rules);
6aff7845 969
d9c85e0f 970 $result = $this->dbh->query(
1a293f10 971 "SELECT * FROM ttrss_filters2_actions WHERE filter_id = '$id' ORDER BY id LIMIT 1");
bcd4d240 972
1a293f10 973 $actions = "";
da46d21e 974
d9c85e0f
AD
975 if ($this->dbh->num_rows($result) > 0) {
976 $line = $this->dbh->fetch_assoc($result);
1a293f10 977 $actions = $this->getActionName($line);
da46d21e 978
1a293f10 979 $num_actions -= 1;
6aff7845
AD
980 }
981
1a293f10
AD
982 if ($num_actions > 0)
983 $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", $num_actions), $actions, $num_actions);
6aff7845 984
1a293f10 985 return array($title, $actions);
6aff7845
AD
986 }
987
988 function join() {
d9c85e0f 989 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
6aff7845
AD
990
991 if (count($ids) > 1) {
992 $base_id = array_shift($ids);
993 $ids_str = join(",", $ids);
994
d9c85e0f
AD
995 $this->dbh->query("BEGIN");
996 $this->dbh->query("UPDATE ttrss_filters2_rules
6aff7845 997 SET filter_id = '$base_id' WHERE filter_id IN ($ids_str)");
d9c85e0f 998 $this->dbh->query("UPDATE ttrss_filters2_actions
6aff7845
AD
999 SET filter_id = '$base_id' WHERE filter_id IN ($ids_str)");
1000
d9c85e0f
AD
1001 $this->dbh->query("DELETE FROM ttrss_filters2 WHERE id IN ($ids_str)");
1002 $this->dbh->query("UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = '$base_id'");
6aff7845 1003
d9c85e0f 1004 $this->dbh->query("COMMIT");
6aff7845
AD
1005
1006 $this->optimizeFilter($base_id);
1007
1008 }
1009 }
1010
1011 private function optimizeFilter($id) {
d9c85e0f
AD
1012 $this->dbh->query("BEGIN");
1013 $result = $this->dbh->query("SELECT * FROM ttrss_filters2_actions
6aff7845
AD
1014 WHERE filter_id = '$id'");
1015
1016 $tmp = array();
1017 $dupe_ids = array();
1018
d9c85e0f 1019 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
1020 $id = $line["id"];
1021 unset($line["id"]);
1022
1023 if (array_search($line, $tmp) === false) {
1024 array_push($tmp, $line);
1025 } else {
1026 array_push($dupe_ids, $id);
1027 }
1028 }
1029
1030 if (count($dupe_ids) > 0) {
1031 $ids_str = join(",", $dupe_ids);
d9c85e0f 1032 $this->dbh->query("DELETE FROM ttrss_filters2_actions
6aff7845
AD
1033 WHERE id IN ($ids_str)");
1034 }
1035
d9c85e0f 1036 $result = $this->dbh->query("SELECT * FROM ttrss_filters2_rules
6aff7845
AD
1037 WHERE filter_id = '$id'");
1038
1039 $tmp = array();
1040 $dupe_ids = array();
1041
d9c85e0f 1042 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
1043 $id = $line["id"];
1044 unset($line["id"]);
1045
1046 if (array_search($line, $tmp) === false) {
1047 array_push($tmp, $line);
1048 } else {
1049 array_push($dupe_ids, $id);
1050 }
1051 }
1052
1053 if (count($dupe_ids) > 0) {
1054 $ids_str = join(",", $dupe_ids);
d9c85e0f 1055 $this->dbh->query("DELETE FROM ttrss_filters2_rules
6aff7845
AD
1056 WHERE id IN ($ids_str)");
1057 }
1058
d9c85e0f 1059 $this->dbh->query("COMMIT");
6aff7845 1060 }
8e17d663
AD
1061}
1062?>