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