summaryrefslogtreecommitdiff
path: root/modules/pref-filters.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2010-11-20 21:08:12 +0300
committerAndrew Dolgov <[email protected]>2010-11-20 21:08:12 +0300
commite43399b79b54ee22446e22c5cbe7123b0f42d703 (patch)
tree26600f8140f192eb0d37fb067c19d101b5adae92 /modules/pref-filters.php
parent11b9d0becdfc894c04afaa912798917911ff35a8 (diff)
pref-filters: fix malformed JSON when there are no filters defined
Diffstat (limited to 'modules/pref-filters.php')
-rw-r--r--modules/pref-filters.php101
1 files changed, 52 insertions, 49 deletions
diff --git a/modules/pref-filters.php b/modules/pref-filters.php
index 527df08a6..7ae547267 100644
--- a/modules/pref-filters.php
+++ b/modules/pref-filters.php
@@ -35,61 +35,64 @@
$cat = false;
$cur_action_description = "";
- while ($line = db_fetch_assoc($result)) {
- if ($cur_action_description != $line['action_description']) {
-
- if ($cat)
- array_push($root['items'], $cat);
-
- $cat = array();
- $cat['id'] = 'ACTION:' . $line['action_id'];
- $cat['name'] = $line['action_description'];
- $cat['items'] = array();
-
- $cur_action_description = $line['action_description'];
- }
-
- if (array_search($line["action_name"],
- array("score", "tag", "label")) === false) {
-
- $line["action_param"] = '';
- } else {
- if ($line['action_name'] == 'label') {
+ if (db_num_rows($result) > 0) {
- $tmp_result = db_query($link, "SELECT fg_color, bg_color
- FROM ttrss_labels2 WHERE caption = '".
- db_escape_string($line["action_param"])."' AND
- owner_uid = " . $_SESSION["uid"]);
-
- if (db_num_rows($tmp_result) != 0) {
- $fg_color = db_fetch_result($tmp_result, 0, "fg_color");
- $bg_color = db_fetch_result($tmp_result, 0, "bg_color");
-
- $tmp = "<span class=\"labelColorIndicator\" style='color : $fg_color; background-color : $bg_color'>&alpha;</span> " . $line['action_param'];
-
- $line['action_param'] = $tmp;
+ while ($line = db_fetch_assoc($result)) {
+ if ($cur_action_description != $line['action_description']) {
+
+ if ($cat)
+ array_push($root['items'], $cat);
+
+ $cat = array();
+ $cat['id'] = 'ACTION:' . $line['action_id'];
+ $cat['name'] = $line['action_description'];
+ $cat['items'] = array();
+
+ $cur_action_description = $line['action_description'];
+ }
+
+ if (array_search($line["action_name"],
+ array("score", "tag", "label")) === false) {
+
+ $line["action_param"] = '';
+ } else {
+ if ($line['action_name'] == 'label') {
+
+ $tmp_result = db_query($link, "SELECT fg_color, bg_color
+ FROM ttrss_labels2 WHERE caption = '".
+ db_escape_string($line["action_param"])."' AND
+ owner_uid = " . $_SESSION["uid"]);
+
+ if (db_num_rows($tmp_result) != 0) {
+ $fg_color = db_fetch_result($tmp_result, 0, "fg_color");
+ $bg_color = db_fetch_result($tmp_result, 0, "bg_color");
+
+ $tmp = "<span class=\"labelColorIndicator\" style='color : $fg_color; background-color : $bg_color'>&alpha;</span> " . $line['action_param'];
+
+ $line['action_param'] = $tmp;
+ }
}
}
+
+ $filter = array();
+ $filter['id'] = 'FILTER:' . $line['id'];
+ $filter['bare_id'] = $line['id'];
+ $filter['name'] = $line['reg_exp'];
+ $filter['type'] = $line['filter_type'];
+ $filter['enabled'] = sql_bool_to_bool($line['enabled']);
+ $filter['param'] = $line['action_param'];
+ $filter['inverse'] = sql_bool_to_bool($line['inverse']);
+ $filter['checkbox'] = false;
+
+ if ($line['feed_id'])
+ $filter['feed'] = $line['feed_title'];
+
+ array_push($cat['items'], $filter);
}
-
- $filter = array();
- $filter['id'] = 'FILTER:' . $line['id'];
- $filter['bare_id'] = $line['id'];
- $filter['name'] = $line['reg_exp'];
- $filter['type'] = $line['filter_type'];
- $filter['enabled'] = sql_bool_to_bool($line['enabled']);
- $filter['param'] = $line['action_param'];
- $filter['inverse'] = sql_bool_to_bool($line['inverse']);
- $filter['checkbox'] = false;
-
- if ($line['feed_id'])
- $filter['feed'] = $line['feed_title'];
-
- array_push($cat['items'], $filter);
+
+ array_push($root['items'], $cat);
}
- array_push($root['items'], $cat);
-
$fl = array();
$fl['identifier'] = 'id';
$fl['label'] = 'name';