]> git.wh0rd.org - tt-rss.git/blame - classes/pref/filters.php
batch feed editor: remove title and feed url because batch editing those makes no...
[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"]);
6aff7845 588
d9c85e0f 589 $this->dbh->query("BEGIN");
6aff7845
AD
590
591 /* create base filter */
592
d9c85e0f 593 $result = $this->dbh->query("INSERT INTO ttrss_filters2
18ad09af
AD
594 (owner_uid, match_any_rule, enabled, title) VALUES
595 (".$_SESSION["uid"].",$match_any_rule,$enabled, '$title')");
6aff7845 596
d9c85e0f 597 $result = $this->dbh->query("SELECT MAX(id) AS id FROM ttrss_filters2
6aff7845
AD
598 WHERE owner_uid = ".$_SESSION["uid"]);
599
d9c85e0f 600 $filter_id = $this->dbh->fetch_result($result, 0, "id");
6aff7845
AD
601
602 $this->saveRulesAndActions($filter_id);
603
d9c85e0f 604 $this->dbh->query("COMMIT");
8e17d663
AD
605 }
606
607 function index() {
608
d9c85e0f 609 $sort = $this->dbh->escape_string($_REQUEST["sort"]);
8e17d663
AD
610
611 if (!$sort || $sort == "undefined") {
612 $sort = "reg_exp";
613 }
614
d9c85e0f 615 $filter_search = $this->dbh->escape_string($_REQUEST["search"]);
8e17d663
AD
616
617 if (array_key_exists("search", $_REQUEST)) {
618 $_SESSION["prefs_filter_search"] = $filter_search;
619 } else {
620 $filter_search = $_SESSION["prefs_filter_search"];
621 }
622
623 print "<div id=\"pref-filter-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
624 print "<div id=\"pref-filter-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
625 print "<div id=\"pref-filter-toolbar\" dojoType=\"dijit.Toolbar\">";
626
d9c85e0f 627 $filter_search = $this->dbh->escape_string($_REQUEST["search"]);
310fa2dd
AD
628
629 if (array_key_exists("search", $_REQUEST)) {
630 $_SESSION["prefs_filter_search"] = $filter_search;
631 } else {
632 $filter_search = $_SESSION["prefs_filter_search"];
633 }
634
635 print "<div style='float : right; padding-right : 4px;'>
636 <input dojoType=\"dijit.form.TextBox\" id=\"filter_search\" size=\"20\" type=\"search\"
637 value=\"$filter_search\">
638 <button dojoType=\"dijit.form.Button\" onclick=\"updateFilterList()\">".
639 __('Search')."</button>
640 </div>";
641
8e17d663
AD
642 print "<div dojoType=\"dijit.form.DropDownButton\">".
643 "<span>" . __('Select')."</span>";
644 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
645 print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\"
646 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
647 print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\"
648 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
649 print "</div></div>";
650
651 print "<button dojoType=\"dijit.form.Button\" onclick=\"return quickAddFilter()\">".
652 __('Create filter')."</button> ";
653
6aff7845
AD
654 print "<button dojoType=\"dijit.form.Button\" onclick=\"return joinSelectedFilters()\">".
655 __('Combine')."</button> ";
656
8e17d663
AD
657 print "<button dojoType=\"dijit.form.Button\" onclick=\"return editSelectedFilter()\">".
658 __('Edit')."</button> ";
659
a86ba0a6
AD
660 print "<button dojoType=\"dijit.form.Button\" onclick=\"return resetFilterOrder()\">".
661 __('Reset sort order')."</button> ";
662
663
8e17d663
AD
664 print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">".
665 __('Remove')."</button> ";
666
667 if (defined('_ENABLE_FEED_DEBUGGING')) {
668 print "<button dojoType=\"dijit.form.Button\" onclick=\"rescore_all_feeds()\">".
669 __('Rescore articles')."</button> ";
670 }
671
672 print "</div>"; # toolbar
673 print "</div>"; # toolbar-frame
674 print "<div id=\"pref-filter-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
675
676 print "<div id=\"filterlistLoading\">
677 <img src='images/indicator_tiny.gif'>".
678 __("Loading, please wait...")."</div>";
679
a86ba0a6 680 print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\"
8e17d663
AD
681 url=\"backend.php?op=pref-filters&method=getfiltertree\">
682 </div>
683 <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\"
a86ba0a6 684 query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Filters\"
8e17d663
AD
685 childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">
686 </div>
687 <div dojoType=\"fox.PrefFilterTree\" id=\"filterTree\"
a86ba0a6
AD
688 dndController=\"dijit.tree.dndSource\"
689 betweenThreshold=\"5\"
8e17d663
AD
690 model=\"filterModel\" openOnClick=\"true\">
691 <script type=\"dojo/method\" event=\"onLoad\" args=\"item\">
692 Element.hide(\"filterlistLoading\");
693 </script>
694 <script type=\"dojo/method\" event=\"onClick\" args=\"item\">
695 var id = String(item.id);
696 var bare_id = id.substr(id.indexOf(':')+1);
697
698 if (id.match('FILTER:')) {
699 editFilter(bare_id);
700 }
701 </script>
702
703 </div>";
704
705 print "</div>"; #pane
6065f3ad 706
1ffe3391 707 PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
6065f3ad
AD
708 "hook_prefs_tab", "prefFilters");
709
8e17d663
AD
710 print "</div>"; #container
711
712 }
6aff7845
AD
713
714 function newfilter() {
715
716 print "<form name='filter_new_form' id='filter_new_form'>";
717
6aff7845
AD
718 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
719 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
720 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
721
18ad09af
AD
722 print "<div class=\"dlgSec\">".__("Caption")."</div>";
723
442bca27 724 print "<input required=\"true\" dojoType=\"dijit.form.ValidationTextBox\" style=\"width : 20em;\" name=\"title\" value=\"\">";
18ad09af 725
6aff7845
AD
726 print "<div class=\"dlgSec\">".__("Match")."</div>";
727
728 print "<div dojoType=\"dijit.Toolbar\">";
729
730 print "<div dojoType=\"dijit.form.DropDownButton\">".
731 "<span>" . __('Select')."</span>";
732 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
733 print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\"
734 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
735 print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\"
736 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
737 print "</div></div>";
738
739 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addRule()\">".
740 __('Add')."</button> ";
741
742 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">".
743 __('Delete')."</button> ";
744
745 print "</div>";
746
747 print "<ul id='filterDlg_Matches'>";
748# print "<li>No rules</li>";
749 print "</ul>";
750
751 print "</div>";
752
753 print "<div class=\"dlgSec\">".__("Apply actions")."</div>";
754
755 print "<div dojoType=\"dijit.Toolbar\">";
756
757 print "<div dojoType=\"dijit.form.DropDownButton\">".
758 "<span>" . __('Select')."</span>";
759 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
760 print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\"
761 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
762 print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\"
763 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
764 print "</div></div>";
765
766 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addAction()\">".
767 __('Add')."</button> ";
768
769 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">".
770 __('Delete')."</button> ";
771
772 print "</div>";
773
774 print "<ul id='filterDlg_Actions'>";
775# print "<li>No actions</li>";
776 print "</ul>";
777
778/* print "<div class=\"dlgSec\">".__("Options")."</div>";
779 print "<div class=\"dlgSecCont\">"; */
780
781 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
782 <label for=\"enabled\">".__('Enabled')."</label>";
783
784 print "<br/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"match_any_rule\" id=\"match_any_rule\">
785 <label for=\"match_any_rule\">".__('Match any rule')."</label>";
786
a3a896a1
AD
787 print "<br/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
788 <label for=\"inverse\">".__('Inverse matching')."</label>";
6aff7845
AD
789
790// print "</div>";
791
792 print "<div class=\"dlgButtons\">";
793
4e02f582
AD
794 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
795 __('Test')."</button> ";
6aff7845
AD
796
797 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
798 __('Create')."</button> ";
799
800 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
801 __('Cancel')."</button>";
802
803 print "</div>";
804
805 }
806
807 function newrule() {
808 $rule = json_decode($_REQUEST["rule"], true);
809
810 if ($rule) {
811 $reg_exp = htmlspecialchars($rule["reg_exp"]);
812 $filter_type = $rule["filter_type"];
813 $feed_id = $rule["feed_id"];
a3a896a1 814 $inverse_checked = isset($rule["inverse"]) ? "checked" : "";
6aff7845
AD
815 } else {
816 $reg_exp = "";
817 $filter_type = 1;
818 $feed_id = 0;
a3a896a1 819 $inverse_checked = "";
6aff7845
AD
820 }
821
822 if (strpos($feed_id, "CAT:") === 0) {
823 $feed_id = substr($feed_id, 4);
824 $cat_filter = true;
825 } else {
826 $cat_filter = false;
827 }
828
829
830 print "<form name='filter_new_rule_form' id='filter_new_rule_form'>";
831
d9c85e0f 832 $result = $this->dbh->query("SELECT id,description
37f78940 833 FROM ttrss_filter_types WHERE id != 5 ORDER BY description");
6aff7845
AD
834
835 $filter_types = array();
836
d9c85e0f 837 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
838 $filter_types[$line["id"]] = __($line["description"]);
839 }
840
841 print "<div class=\"dlgSec\">".__("Match")."</div>";
842
843 print "<div class=\"dlgSecCont\">";
844
845 print "<input dojoType=\"dijit.form.ValidationTextBox\"
846 required=\"true\" id=\"filterDlg_regExp\"
ff34bac2 847 style=\"font-size : 16px; width : 20em;\"
6aff7845
AD
848 name=\"reg_exp\" value=\"$reg_exp\"/>";
849
ec1f8a3d
AD
850 print "<hr/>";
851 print "<input id=\"filterDlg_inverse\" dojoType=\"dijit.form.CheckBox\"
852 name=\"inverse\" $inverse_checked/>";
853 print "<label for=\"filterDlg_inverse\">".__("Inverse regular expression matching")."</label>";
854
6aff7845
AD
855 print "<hr/>" . __("on field") . " ";
856 print_select_hash("filter_type", $filter_type, $filter_types,
857 'dojoType="dijit.form.Select"');
858
859 print "<hr/>";
860
861 print __("in") . " ";
862
863 print "<span id='filterDlg_feeds'>";
a42c55f0 864 print_feed_select("feed_id",
6aff7845
AD
865 $cat_filter ? "CAT:$feed_id" : $feed_id,
866 'dojoType="dijit.form.FilteringSelect"');
867 print "</span>";
868
869 print "</div>";
870
871 print "<div class=\"dlgButtons\">";
872
873 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewRuleDlg').execute()\">".
874 ($rule ? __("Save rule") : __('Add rule'))."</button> ";
875
876 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewRuleDlg').hide()\">".
877 __('Cancel')."</button>";
878
879 print "</div>";
880
881 print "</form>";
882 }
883
884 function newaction() {
885 $action = json_decode($_REQUEST["action"], true);
886
887 if ($action) {
d9c85e0f 888 $action_param = $this->dbh->escape_string($action["action_param"]);
6aff7845
AD
889 $action_id = (int)$action["action_id"];
890 } else {
891 $action_param = "";
892 $action_id = 0;
893 }
894
895 print "<form name='filter_new_action_form' id='filter_new_action_form'>";
896
897 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
898
899 print "<div class=\"dlgSecCont\">";
900
901 print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
902 onchange=\"filterDlgCheckAction(this)\">";
903
d9c85e0f 904 $result = $this->dbh->query("SELECT id,description FROM ttrss_filter_actions
6aff7845
AD
905 ORDER BY name");
906
d9c85e0f 907 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
908 $is_selected = ($line["id"] == $action_id) ? "selected='1'" : "";
909 printf("<option $is_selected value='%d'>%s</option>", $line["id"], __($line["description"]));
910 }
911
912 print "</select>";
913
914 $param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6) ?
915 "" : "display : none";
916
917 $param_hidden = ($action_id == 4 || $action_id == 6) ?
918 "" : "display : none";
919
920 $label_param_hidden = ($action_id == 7) ? "" : "display : none";
921
922 print "<span id=\"filterDlg_paramBox\" style=\"$param_box_hidden\">";
923 print " " . __("with parameters:") . " ";
924 print "<input dojoType=\"dijit.form.TextBox\"
925 id=\"filterDlg_actionParam\" style=\"$param_hidden\"
926 name=\"action_param\" value=\"$action_param\">";
927
a42c55f0 928 print_label_select("action_param_label", $action_param,
6aff7845
AD
929 "id=\"filterDlg_actionParamLabel\" style=\"$label_param_hidden\"
930 dojoType=\"dijit.form.Select\"");
931
932 print "</span>";
933
934 print "&nbsp;"; // tiny layout hack
935
936 print "</div>";
937
938 print "<div class=\"dlgButtons\">";
939
940 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewActionDlg').execute()\">".
941 ($action ? __("Save action") : __('Add action'))."</button> ";
942
943 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewActionDlg').hide()\">".
944 __('Cancel')."</button>";
945
946 print "</div>";
947
948 print "</form>";
949 }
950
951 private function getFilterName($id) {
18ad09af 952
d9c85e0f 953 $result = $this->dbh->query(
1a293f10
AD
954 "SELECT title,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
955 FROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r
956 ON (r.filter_id = f.id)
957 LEFT JOIN ttrss_filters2_actions AS a
958 ON (a.filter_id = f.id) WHERE f.id = '$id' GROUP BY f.title");
18ad09af 959
d9c85e0f
AD
960 $title = $this->dbh->fetch_result($result, 0, "title");
961 $num_rules = $this->dbh->fetch_result($result, 0, "num_rules");
962 $num_actions = $this->dbh->fetch_result($result, 0, "num_actions");
18ad09af 963
1a293f10 964 if (!$title) $title = __("[No caption]");
18ad09af 965
1a293f10 966 $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", $num_rules), $title, $num_rules);
6aff7845 967
d9c85e0f 968 $result = $this->dbh->query(
1a293f10 969 "SELECT * FROM ttrss_filters2_actions WHERE filter_id = '$id' ORDER BY id LIMIT 1");
bcd4d240 970
1a293f10 971 $actions = "";
da46d21e 972
d9c85e0f
AD
973 if ($this->dbh->num_rows($result) > 0) {
974 $line = $this->dbh->fetch_assoc($result);
1a293f10 975 $actions = $this->getActionName($line);
da46d21e 976
1a293f10 977 $num_actions -= 1;
6aff7845
AD
978 }
979
1a293f10
AD
980 if ($num_actions > 0)
981 $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", $num_actions), $actions, $num_actions);
6aff7845 982
1a293f10 983 return array($title, $actions);
6aff7845
AD
984 }
985
986 function join() {
d9c85e0f 987 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
6aff7845
AD
988
989 if (count($ids) > 1) {
990 $base_id = array_shift($ids);
991 $ids_str = join(",", $ids);
992
d9c85e0f
AD
993 $this->dbh->query("BEGIN");
994 $this->dbh->query("UPDATE ttrss_filters2_rules
6aff7845 995 SET filter_id = '$base_id' WHERE filter_id IN ($ids_str)");
d9c85e0f 996 $this->dbh->query("UPDATE ttrss_filters2_actions
6aff7845
AD
997 SET filter_id = '$base_id' WHERE filter_id IN ($ids_str)");
998
d9c85e0f
AD
999 $this->dbh->query("DELETE FROM ttrss_filters2 WHERE id IN ($ids_str)");
1000 $this->dbh->query("UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = '$base_id'");
6aff7845 1001
d9c85e0f 1002 $this->dbh->query("COMMIT");
6aff7845
AD
1003
1004 $this->optimizeFilter($base_id);
1005
1006 }
1007 }
1008
1009 private function optimizeFilter($id) {
d9c85e0f
AD
1010 $this->dbh->query("BEGIN");
1011 $result = $this->dbh->query("SELECT * FROM ttrss_filters2_actions
6aff7845
AD
1012 WHERE filter_id = '$id'");
1013
1014 $tmp = array();
1015 $dupe_ids = array();
1016
d9c85e0f 1017 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
1018 $id = $line["id"];
1019 unset($line["id"]);
1020
1021 if (array_search($line, $tmp) === false) {
1022 array_push($tmp, $line);
1023 } else {
1024 array_push($dupe_ids, $id);
1025 }
1026 }
1027
1028 if (count($dupe_ids) > 0) {
1029 $ids_str = join(",", $dupe_ids);
d9c85e0f 1030 $this->dbh->query("DELETE FROM ttrss_filters2_actions
6aff7845
AD
1031 WHERE id IN ($ids_str)");
1032 }
1033
d9c85e0f 1034 $result = $this->dbh->query("SELECT * FROM ttrss_filters2_rules
6aff7845
AD
1035 WHERE filter_id = '$id'");
1036
1037 $tmp = array();
1038 $dupe_ids = array();
1039
d9c85e0f 1040 while ($line = $this->dbh->fetch_assoc($result)) {
6aff7845
AD
1041 $id = $line["id"];
1042 unset($line["id"]);
1043
1044 if (array_search($line, $tmp) === false) {
1045 array_push($tmp, $line);
1046 } else {
1047 array_push($dupe_ids, $id);
1048 }
1049 }
1050
1051 if (count($dupe_ids) > 0) {
1052 $ids_str = join(",", $dupe_ids);
d9c85e0f 1053 $this->dbh->query("DELETE FROM ttrss_filters2_rules
6aff7845
AD
1054 WHERE id IN ($ids_str)");
1055 }
1056
d9c85e0f 1057 $this->dbh->query("COMMIT");
6aff7845 1058 }
8e17d663
AD
1059}
1060?>