new style labels (bump schema)
This commit is contained in:
parent
abd9b16507
commit
ceb30ba49d
50
backend.php
50
backend.php
|
@ -467,56 +467,6 @@
|
||||||
}
|
}
|
||||||
break; // rss
|
break; // rss
|
||||||
|
|
||||||
case "labelFromSearch":
|
|
||||||
$search = db_escape_string($_GET["search"]);
|
|
||||||
$search_mode = db_escape_string($_GET["smode"]);
|
|
||||||
$match_on = db_escape_string($_GET["match"]);
|
|
||||||
$is_cat = db_escape_string($_GET["is_cat"]);
|
|
||||||
$title = db_escape_string($_GET["title"]);
|
|
||||||
$feed = sprintf("%d", $_GET["feed"]);
|
|
||||||
|
|
||||||
$label_qparts = array();
|
|
||||||
|
|
||||||
$search_expr = getSearchSql($search, $match_on);
|
|
||||||
|
|
||||||
if ($is_cat) {
|
|
||||||
if ($feed != 0) {
|
|
||||||
$search_expr .= " AND ttrss_feeds.cat_id = $feed ";
|
|
||||||
} else {
|
|
||||||
$search_expr .= " AND ttrss_feeds.cat_id IS NULL ";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($search_mode == "all_feeds") {
|
|
||||||
// NOOP
|
|
||||||
} else if ($search_mode == "this_cat") {
|
|
||||||
|
|
||||||
$tmp_result = db_query($link, "SELECT cat_id
|
|
||||||
FROM ttrss_feeds WHERE id = '$feed'");
|
|
||||||
|
|
||||||
$cat_id = db_fetch_result($tmp_result, 0, "cat_id");
|
|
||||||
|
|
||||||
if ($cat_id > 0) {
|
|
||||||
$search_expr .= " AND ttrss_feeds.cat_id = $cat_id ";
|
|
||||||
} else {
|
|
||||||
$search_expr .= " AND ttrss_feeds.cat_id IS NULL ";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$search_expr .= " AND ttrss_feeds.id = $feed ";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$search_expr = db_escape_string($search_expr);
|
|
||||||
|
|
||||||
print $search_expr;
|
|
||||||
|
|
||||||
if ($title) {
|
|
||||||
$result = db_query($link,
|
|
||||||
"INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
|
|
||||||
VALUES ('$search_expr', '$title', '".$_SESSION["uid"]."')");
|
|
||||||
}
|
|
||||||
break; // labelFromSearch
|
|
||||||
|
|
||||||
case "getUnread":
|
case "getUnread":
|
||||||
$login = db_escape_string($_GET["login"]);
|
$login = db_escape_string($_GET["login"]);
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,6 @@
|
||||||
// some use-cases (if you have more than one tt-rss window open, for example)
|
// some use-cases (if you have more than one tt-rss window open, for example)
|
||||||
// so it is disabled by default.
|
// so it is disabled by default.
|
||||||
|
|
||||||
define('GLOBAL_ENABLE_LABELS', false);
|
|
||||||
// Labels are a security risk, so this option can globally disable them for all users.
|
|
||||||
|
|
||||||
define('MAIL_RESET_PASS', true);
|
define('MAIL_RESET_PASS', true);
|
||||||
// Send mail to user on password reset
|
// Send mail to user on password reset
|
||||||
|
|
||||||
|
|
|
@ -1557,8 +1557,15 @@ function filterDlgCheckAction(sender) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if selected action supports parameters, enable params field
|
// if selected action supports parameters, enable params field
|
||||||
if (action == 4 || action == 6) {
|
if (action == 4 || action == 6 || action == 7) {
|
||||||
Element.show(action_param);
|
Element.show(action_param);
|
||||||
|
if (action != 7) {
|
||||||
|
Element.show(form.action_param);
|
||||||
|
Element.hide(form.action_param_label);
|
||||||
|
} else {
|
||||||
|
Element.show(form.action_param_label);
|
||||||
|
Element.hide(form.action_param);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Element.hide(action_param);
|
Element.hide(action_param);
|
||||||
}
|
}
|
||||||
|
|
236
functions.php
236
functions.php
|
@ -1300,6 +1300,13 @@
|
||||||
|
|
||||||
db_query($link, "COMMIT");
|
db_query($link, "COMMIT");
|
||||||
|
|
||||||
|
if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
|
||||||
|
_debug("update_rss_feed: assigning labels...");
|
||||||
|
}
|
||||||
|
|
||||||
|
assign_article_to_labels($link, $entry_ref_id, $article_filters,
|
||||||
|
$owner_uid);
|
||||||
|
|
||||||
if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
|
if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
|
||||||
_debug("update_rss_feed: looking for enclosures...");
|
_debug("update_rss_feed: looking for enclosures...");
|
||||||
}
|
}
|
||||||
|
@ -1588,6 +1595,13 @@
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assign_article_to_labels($link, $id, $filters, $owner_uid) {
|
||||||
|
foreach ($filters as $f) {
|
||||||
|
if ($f[0] == "label") {
|
||||||
|
label_add_article($link, $id, $f[1], $owner_uid);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
|
function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
|
||||||
$rtl_content = false, $last_updated = false, $last_error = false) {
|
$rtl_content = false, $last_updated = false, $last_error = false) {
|
||||||
|
@ -1822,11 +1836,11 @@
|
||||||
|
|
||||||
function initialize_user($link, $uid) {
|
function initialize_user($link, $uid) {
|
||||||
|
|
||||||
db_query($link, "insert into ttrss_labels (owner_uid,sql_exp,description)
|
/* db_query($link, "insert into ttrss_labels (owner_uid,sql_exp,description)
|
||||||
values ('$uid','unread = true', 'Unread articles')");
|
values ('$uid','unread = true', 'Unread articles')");
|
||||||
|
|
||||||
db_query($link, "insert into ttrss_labels (owner_uid,sql_exp,description)
|
db_query($link, "insert into ttrss_labels (owner_uid,sql_exp,description)
|
||||||
values ('$uid','last_read is null and unread = false', 'Updated articles')");
|
values ('$uid','last_read is null and unread = false', 'Updated articles')"); */
|
||||||
|
|
||||||
db_query($link, "insert into ttrss_feeds (owner_uid,title,feed_url)
|
db_query($link, "insert into ttrss_feeds (owner_uid,title,feed_url)
|
||||||
values ('$uid', 'Tiny Tiny RSS: New Releases',
|
values ('$uid', 'Tiny Tiny RSS: New Releases',
|
||||||
|
@ -2398,7 +2412,9 @@
|
||||||
return getFeedUnread($link, -1) + getFeedUnread($link, -2) + getFeedUnread($link, -3);
|
return getFeedUnread($link, -1) + getFeedUnread($link, -2) + getFeedUnread($link, -3);
|
||||||
} else if ($cat == -2) {
|
} else if ($cat == -2) {
|
||||||
|
|
||||||
$rv = getLabelCounters($link, false, true);
|
// FIXME: NEW_LABELS
|
||||||
|
|
||||||
|
/* $rv = getLabelCounters($link, false, true);
|
||||||
$ctr = 0;
|
$ctr = 0;
|
||||||
|
|
||||||
foreach (array_keys($rv) as $k) {
|
foreach (array_keys($rv) as $k) {
|
||||||
|
@ -2407,8 +2423,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ctr;
|
return $ctr; */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMaxAgeSubquery($days = COUNTERS_MAX_AGE) {
|
function getMaxAgeSubquery($days = COUNTERS_MAX_AGE) {
|
||||||
|
@ -2425,6 +2441,22 @@
|
||||||
return getFeedArticles($link, $feed, $is_cat, true, $_SESSION["uid"]);
|
return getFeedArticles($link, $feed, $is_cat, true, $_SESSION["uid"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLabelUnread($link, $label_id, $owner_uid = false) {
|
||||||
|
if (!$owner_uid) $owner_uid = $_SESSION["uid"];
|
||||||
|
|
||||||
|
$result = db_query($link, "
|
||||||
|
SELECT SUM(unread) AS unread FROM
|
||||||
|
ttrss_user_entries, ttrss_labels2, ttrss_user_labels2
|
||||||
|
WHERE label_id = id AND article_id = ref_id AND
|
||||||
|
ttrss_labels2.owner_uid = '$owner_uid' AND id = '$label_id'");
|
||||||
|
|
||||||
|
if (db_num_rows($result) != 0) {
|
||||||
|
return db_fetch_result($result, 0, "unread");
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFeedArticles($link, $feed, $is_cat = false, $unread_only = false,
|
function getFeedArticles($link, $feed, $is_cat = false, $unread_only = false,
|
||||||
$owner_uid = false) {
|
$owner_uid = false) {
|
||||||
|
|
||||||
|
@ -2499,10 +2531,8 @@
|
||||||
|
|
||||||
$label_id = -$feed - 11;
|
$label_id = -$feed - 11;
|
||||||
|
|
||||||
$result = db_query($link, "SELECT sql_exp FROM ttrss_labels WHERE
|
return getLabelUnread($link, $label_id, $owner_uid);
|
||||||
id = '$label_id' AND owner_uid = " . $owner_uid);
|
|
||||||
|
|
||||||
$match_part = db_fetch_result($result, 0, "sql_exp");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($match_part) {
|
if ($match_part) {
|
||||||
|
@ -2626,81 +2656,47 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret_arr = array();
|
$ret_arr = array();
|
||||||
|
|
||||||
|
for ($i = -1; $i >= -3; $i--) {
|
||||||
|
|
||||||
|
$count = getFeedUnread($link, $i);
|
||||||
|
|
||||||
|
if (!$ret_mode) {
|
||||||
|
|
||||||
|
if (get_pref($link, 'EXTENDED_FEEDLIST')) {
|
||||||
|
$xmsg_part = "xmsg=\"(" . getFeedArticles($link, $i) . " total)\"";
|
||||||
|
} else {
|
||||||
|
$xmsg_part = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "<counter type=\"label\" id=\"$i\" counter=\"$count\" $xmsg_part/>";
|
||||||
|
} else {
|
||||||
|
$ret_arr[$i]["counter"] = $count;
|
||||||
|
$ret_arr[$i]["description"] = getFeedTitle($link, $i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$old_counters = $_SESSION["lctr_last_value"];
|
$old_counters = $_SESSION["lctr_last_value"];
|
||||||
$lctrs_modified = false;
|
$lctrs_modified = false;
|
||||||
|
|
||||||
$count = getFeedUnread($link, -1);
|
|
||||||
|
|
||||||
if (!$ret_mode) {
|
$owner_uid = $_SESSION["uid"];
|
||||||
|
|
||||||
if (get_pref($link, 'EXTENDED_FEEDLIST')) {
|
$result = db_query($link,
|
||||||
$xmsg_part = "xmsg=\"(" . getFeedArticles($link, $id) . " total)\"";
|
"SELECT id, caption, SUM(unread) AS unread FROM ttrss_labels2
|
||||||
} else {
|
LEFT JOIN ttrss_user_labels2 ON (label_id = id)
|
||||||
$xmsg_part = "";
|
LEFT JOIN ttrss_user_entries ON (ref_id = article_id)
|
||||||
}
|
WHERE ttrss_labels2.owner_uid = '$owner_uid'
|
||||||
|
GROUP BY id");
|
||||||
print "<counter type=\"label\" id=\"-1\" counter=\"$count\" $xmsg_part/>";
|
|
||||||
} else {
|
|
||||||
$ret_arr["-1"]["counter"] = $count;
|
|
||||||
$ret_arr["-1"]["description"] = __("Starred articles");
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = getFeedUnread($link, -2);
|
|
||||||
|
|
||||||
if (!$ret_mode) {
|
|
||||||
|
|
||||||
if (get_pref($link, 'EXTENDED_FEEDLIST')) {
|
|
||||||
$xmsg_part = "xmsg=\"(" . getFeedArticles($link, $id) . " total)\"";
|
|
||||||
} else {
|
|
||||||
$xmsg_part = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<counter type=\"label\" id=\"-2\" counter=\"$count\" $xmsg_part/>";
|
|
||||||
} else {
|
|
||||||
$ret_arr["-2"]["counter"] = $count;
|
|
||||||
$ret_arr["-2"]["description"] = __("Published articles");
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = getFeedUnread($link, -3);
|
|
||||||
|
|
||||||
if (!$ret_mode) {
|
|
||||||
|
|
||||||
if (get_pref($link, 'EXTENDED_FEEDLIST')) {
|
|
||||||
$xmsg_part = "xmsg=\"(" . getFeedArticles($link, $id) . " total)\"";
|
|
||||||
} else {
|
|
||||||
$xmsg_part = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<counter type=\"label\" id=\"-3\" counter=\"$count\" $xmsg_part/>";
|
|
||||||
} else {
|
|
||||||
$ret_arr["-3"]["counter"] = $count;
|
|
||||||
$ret_arr["-3"]["description"] = __("Fresh articles");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) {
|
|
||||||
|
|
||||||
$result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM
|
|
||||||
ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description");
|
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
$id = -$line["id"] - 11;
|
$id = -$line["id"] - 11;
|
||||||
|
|
||||||
$label_name = $line["description"];
|
$label_name = $line["caption"];
|
||||||
|
$count = $line["unread"];
|
||||||
error_reporting (0);
|
|
||||||
|
|
||||||
$tmp_result = db_query($link, "SELECT count(ttrss_entries.id) as count FROM ttrss_user_entries,ttrss_entries,ttrss_feeds
|
|
||||||
WHERE (" . $line["sql_exp"] . ") AND unread = true AND
|
|
||||||
ttrss_feeds.hidden = false AND
|
|
||||||
$age_qpart AND
|
|
||||||
ttrss_user_entries.feed_id = ttrss_feeds.id AND
|
|
||||||
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
|
||||||
ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
|
|
||||||
|
|
||||||
$count = db_fetch_result($tmp_result, 0, "count");
|
|
||||||
|
|
||||||
if (!$smart_mode || $old_counters[$id] != $count) {
|
if (!$smart_mode || $old_counters[$id] != $count) {
|
||||||
$old_counters[$id] = $count;
|
$old_counters[$id] = $count;
|
||||||
$lctrs_modified = true;
|
$lctrs_modified = true;
|
||||||
|
@ -2721,7 +2717,6 @@
|
||||||
|
|
||||||
error_reporting (DEFAULT_ERROR_LEVEL);
|
error_reporting (DEFAULT_ERROR_LEVEL);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($smart_mode && $lctrs_modified) {
|
if ($smart_mode && $lctrs_modified) {
|
||||||
$_SESSION["lctr_last_value"] = $old_counters;
|
$_SESSION["lctr_last_value"] = $old_counters;
|
||||||
|
@ -3000,9 +2995,9 @@
|
||||||
return __("Fresh articles");
|
return __("Fresh articles");
|
||||||
} else if ($id < -10) {
|
} else if ($id < -10) {
|
||||||
$label_id = -$id - 11;
|
$label_id = -$id - 11;
|
||||||
$result = db_query($link, "SELECT description FROM ttrss_labels WHERE id = '$label_id'");
|
$result = db_query($link, "SELECT caption FROM ttrss_labels2 WHERE id = '$label_id'");
|
||||||
if (db_num_rows($result) == 1) {
|
if (db_num_rows($result) == 1) {
|
||||||
return db_fetch_result($result, 0, "description");
|
return db_fetch_result($result, 0, "caption");
|
||||||
} else {
|
} else {
|
||||||
return "Unknown label ($label_id)";
|
return "Unknown label ($label_id)";
|
||||||
}
|
}
|
||||||
|
@ -3308,17 +3303,14 @@
|
||||||
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
|
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
|
||||||
} else if ($feed <= -10) { // labels
|
} else if ($feed <= -10) { // labels
|
||||||
$label_id = -$feed - 11;
|
$label_id = -$feed - 11;
|
||||||
|
|
||||||
$tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
|
|
||||||
WHERE id = '$label_id'");
|
|
||||||
|
|
||||||
$query_strategy_part = "(" . db_fetch_result($tmp_result, 0, "sql_exp") . ")";
|
|
||||||
|
|
||||||
if (!$query_strategy_part) {
|
$query_strategy_part = "label_id = '$label_id' AND
|
||||||
return false;
|
ttrss_labels2.id = ttrss_user_labels2.label_id AND
|
||||||
}
|
ttrss_user_labels2.article_id = ref_id";
|
||||||
|
|
||||||
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
|
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
|
||||||
|
$ext_tables_part = ",ttrss_labels2,ttrss_user_labels2";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$query_strategy_part = "id > 0"; // dumb
|
$query_strategy_part = "id > 0"; // dumb
|
||||||
}
|
}
|
||||||
|
@ -3386,9 +3378,9 @@
|
||||||
if ($search) { $feed_title = __("Searched for") . " $search ($feed_title)"; }
|
if ($search) { $feed_title = __("Searched for") . " $search ($feed_title)"; }
|
||||||
} else if ($feed < -10) {
|
} else if ($feed < -10) {
|
||||||
$label_id = -$feed - 11;
|
$label_id = -$feed - 11;
|
||||||
$result = db_query($link, "SELECT description FROM ttrss_labels
|
$result = db_query($link, "SELECT caption FROM ttrss_labels2
|
||||||
WHERE id = '$label_id'");
|
WHERE id = '$label_id'");
|
||||||
$feed_title = db_fetch_result($result, 0, "description");
|
$feed_title = db_fetch_result($result, 0, "caption");
|
||||||
|
|
||||||
if ($search) {
|
if ($search) {
|
||||||
$feed_title = __("Searched for") . " $search ($feed_title)";
|
$feed_title = __("Searched for") . " $search ($feed_title)";
|
||||||
|
@ -3440,7 +3432,7 @@
|
||||||
".SUBSTRING_FOR_DATE."(updated,1,19) as updated_noms,
|
".SUBSTRING_FOR_DATE."(updated,1,19) as updated_noms,
|
||||||
author,score
|
author,score
|
||||||
FROM
|
FROM
|
||||||
ttrss_entries,ttrss_user_entries,ttrss_feeds
|
ttrss_entries,ttrss_user_entries,ttrss_feeds$ext_tables_part
|
||||||
WHERE
|
WHERE
|
||||||
$group_limit_part
|
$group_limit_part
|
||||||
ttrss_feeds.hidden = false AND
|
ttrss_feeds.hidden = false AND
|
||||||
|
@ -4055,17 +4047,6 @@
|
||||||
|
|
||||||
print "<li><span class=\"insensitive\">--------</span></li>";
|
print "<li><span class=\"insensitive\">--------</span></li>";
|
||||||
print "<li><span class=\"insensitive\">".__('Other actions:')."</span></li>";
|
print "<li><span class=\"insensitive\">".__('Other actions:')."</span></li>";
|
||||||
|
|
||||||
|
|
||||||
if ($search && $feed_id >= 0 && get_pref($link, 'ENABLE_LABELS') && GLOBAL_ENABLE_LABELS) {
|
|
||||||
print "
|
|
||||||
<li onclick=\"javascript:labelFromSearch('$search', '$search_mode',
|
|
||||||
'$match_on', '$feed_id', '$is_cat');\">
|
|
||||||
".__('Search to label')."</li>";
|
|
||||||
} else {
|
|
||||||
print "<li><span class=\"insensitive\"> ".__('Search to label')."</li>";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</ul></li></ul>";
|
print "</ul></li></ul>";
|
||||||
print "</td>";
|
print "</td>";
|
||||||
|
@ -4085,15 +4066,7 @@
|
||||||
__('Mark as read:')."
|
__('Mark as read:')."
|
||||||
<a href=\"#\" onclick=\"$catchup_page_link\">".__('Page')."</a>,
|
<a href=\"#\" onclick=\"$catchup_page_link\">".__('Page')."</a>,
|
||||||
<a href=\"#\" onclick=\"$catchup_feed_link\">".__('Feed')."</a>";
|
<a href=\"#\" onclick=\"$catchup_feed_link\">".__('Feed')."</a>";
|
||||||
|
|
||||||
if ($search && $feed_id >= 0 && get_pref($link, 'ENABLE_LABELS') && GLOBAL_ENABLE_LABELS) {
|
|
||||||
|
|
||||||
print "
|
|
||||||
<a href=\"javascript:labelFromSearch('$search', '$search_mode',
|
|
||||||
'$match_on', '$feed_id', '$is_cat');\">
|
|
||||||
".__('Convert to label')."</a>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</td>";
|
print "</td>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4258,10 +4231,9 @@
|
||||||
|
|
||||||
if (!$tags) {
|
if (!$tags) {
|
||||||
|
|
||||||
if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) {
|
|
||||||
|
$result = db_query($link, "SELECT id,caption FROM
|
||||||
$result = db_query($link, "SELECT id,sql_exp,description FROM
|
ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");
|
||||||
ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
|
|
||||||
|
|
||||||
if (db_num_rows($result) > 0) {
|
if (db_num_rows($result) > 0) {
|
||||||
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
||||||
|
@ -4281,8 +4253,6 @@
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
error_reporting (0);
|
|
||||||
|
|
||||||
$label_id = -$line['id'] - 11;
|
$label_id = -$line['id'] - 11;
|
||||||
$count = getFeedUnread($link, $label_id);
|
$count = getFeedUnread($link, $label_id);
|
||||||
|
|
||||||
|
@ -4291,11 +4261,9 @@
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
$class .= "Unread";
|
$class .= "Unread";
|
||||||
}
|
}
|
||||||
|
|
||||||
error_reporting (DEFAULT_ERROR_LEVEL);
|
|
||||||
|
|
||||||
printFeedEntry($label_id,
|
printFeedEntry($label_id,
|
||||||
$class, $line["description"],
|
$class, $line["caption"],
|
||||||
$count, "images/label.png", $link);
|
$count, "images/label.png", $link);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4304,9 +4272,8 @@
|
||||||
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
||||||
print "</ul>";
|
print "</ul>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!get_pref($link, 'ENABLE_FEED_CATS')) {
|
if (!get_pref($link, 'ENABLE_FEED_CATS')) {
|
||||||
print "<li><hr></li>";
|
print "<li><hr></li>";
|
||||||
|
@ -6067,4 +6034,37 @@
|
||||||
|
|
||||||
return $unread;
|
return $unread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function label_find_id($link, $label, $owner_uid) {
|
||||||
|
$result = db_query($link,
|
||||||
|
"SELECT id FROM ttrss_labels2 WHERE caption = '$label'
|
||||||
|
AND owner_uid = '$owner_uid' LIMIT 1");
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 1) {
|
||||||
|
return db_fetch_result($result, 0, "id");
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function label_add_article($link, $id, $label, $owner_uid) {
|
||||||
|
|
||||||
|
$label_id = label_find_id($link, $label, $owner_uid);
|
||||||
|
|
||||||
|
if (!$label_id) return;
|
||||||
|
|
||||||
|
$result = db_query($link,
|
||||||
|
"SELECT
|
||||||
|
article_id FROM ttrss_labels2, ttrss_user_labels2
|
||||||
|
WHERE
|
||||||
|
label_id = id AND
|
||||||
|
label_id = '$label_id' AND
|
||||||
|
article_id = '$id' AND owner_uid = '$owner_uid'
|
||||||
|
LIMIT 1");
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 0) {
|
||||||
|
db_query($link, "INSERT INTO ttrss_user_labels2
|
||||||
|
(label_id, article_id) VALUES ('$label_id', '$id')");
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<tr><td class='n'>c T</td><td><?php echo __("Top 25 feeds") ?></td></tr>
|
<tr><td class='n'>c T</td><td><?php echo __("Top 25 feeds") ?></td></tr>
|
||||||
<tr><td class='n'>c c</td><td><?php echo __("Edit feed categories") ?></td></tr>
|
<tr><td class='n'>c c</td><td><?php echo __("Edit feed categories") ?></td></tr>
|
||||||
<tr><td class='n'>c f</td><td><?php echo __("Create filter") ?></td></tr>
|
<tr><td class='n'>c f</td><td><?php echo __("Create filter") ?></td></tr>
|
||||||
<tr><td class='n'>c l</td><td><?php echo __("Create label") ?></td></tr>
|
<!-- <tr><td class='n'>c l</td><td><?php echo __("Create label") ?></td></tr> -->
|
||||||
<!-- <tr><td class='n'>c u</td><td><?php echo __("Create user") ?></td></tr> -->
|
<!-- <tr><td class='n'>c u</td><td><?php echo __("Create user") ?></td></tr> -->
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -65,11 +65,10 @@
|
||||||
print "</ul>";
|
print "</ul>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) {
|
|
||||||
|
|
||||||
$result = db_query($link, "SELECT id,description FROM
|
$result = db_query($link, "SELECT id,caption FROM
|
||||||
ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
|
ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");
|
||||||
|
|
||||||
if (db_num_rows($result) > 0) {
|
if (db_num_rows($result) > 0) {
|
||||||
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
||||||
print "<li class=\"feedCat\">".__("Labels")."</li>";
|
print "<li class=\"feedCat\">".__("Labels")."</li>";
|
||||||
|
@ -81,8 +80,6 @@
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
error_reporting (0);
|
|
||||||
|
|
||||||
$count = getFeedUnread($link, -$line["id"]-11);
|
$count = getFeedUnread($link, -$line["id"]-11);
|
||||||
|
|
||||||
$class = "label";
|
$class = "label";
|
||||||
|
@ -90,11 +87,9 @@
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
$class .= "Unread";
|
$class .= "Unread";
|
||||||
}
|
}
|
||||||
|
|
||||||
error_reporting (DEFAULT_ERROR_LEVEL);
|
|
||||||
|
|
||||||
printMobileFeedEntry(-$line["id"]-11,
|
printMobileFeedEntry(-$line["id"]-11,
|
||||||
$class, $line["description"], $count, "../images/label.png", $link);
|
$class, $line["caption"], $count, "../images/label.png", $link);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +99,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
||||||
$order_by_qpart = "category,title";
|
$order_by_qpart = "category,title";
|
||||||
|
|
|
@ -219,7 +219,7 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id == "quickAddLabel") {
|
/* if ($id == "quickAddLabel") {
|
||||||
print "<div id=\"infoBoxTitle\">".__('Create Label')."</div>";
|
print "<div id=\"infoBoxTitle\">".__('Create Label')."</div>";
|
||||||
print "<div class=\"infoBoxContents\">";
|
print "<div class=\"infoBoxContents\">";
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@
|
||||||
value=\"".__('Cancel')."\">";
|
value=\"".__('Cancel')."\">";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} */
|
||||||
|
|
||||||
if ($id == "quickAddFilter") {
|
if ($id == "quickAddFilter") {
|
||||||
|
|
||||||
|
|
|
@ -98,13 +98,22 @@
|
||||||
|
|
||||||
print "</select>";
|
print "</select>";
|
||||||
|
|
||||||
$param_hidden = ($action_id == 4 || $action_id == 6) ? "" : "display : none";
|
$param_hidden = ($action_id == 4 || $action_id == 6 || $action_id == 7) ? "" : "display : none";
|
||||||
|
|
||||||
print "<span id=\"filter_dlg_param_box\" style=\"$param_hidden\">";
|
print "<span id=\"filter_dlg_param_box\" style=\"$param_hidden\">";
|
||||||
print " " . __("with parameters:") . " ";
|
print " " . __("with parameters:") . " ";
|
||||||
print "<input size=\"20\"
|
|
||||||
|
$param_int_hidden = ($action_id != 7) ? "" : "display : none";
|
||||||
|
|
||||||
|
print "<input size=\"20\" style=\"$param_int_hidden\"
|
||||||
onkeypress=\"return filterCR(event, filterEditSave)\"
|
onkeypress=\"return filterCR(event, filterEditSave)\"
|
||||||
name=\"action_param\" value=\"$action_param\">";
|
name=\"action_param\" value=\"$action_param\">";
|
||||||
|
|
||||||
|
$param_int_hidden = ($action_id == 7) ? "" : "display : none";
|
||||||
|
|
||||||
|
print_label_select($link, "action_param_label", $action_param,
|
||||||
|
$param_int_hidden);
|
||||||
|
|
||||||
print "</span>";
|
print "</span>";
|
||||||
|
|
||||||
print " "; // tiny layout hack
|
print " "; // tiny layout hack
|
||||||
|
@ -170,6 +179,7 @@
|
||||||
$feed_id = db_escape_string($_GET["feed_id"]);
|
$feed_id = db_escape_string($_GET["feed_id"]);
|
||||||
$action_id = db_escape_string($_GET["action_id"]);
|
$action_id = db_escape_string($_GET["action_id"]);
|
||||||
$action_param = db_escape_string($_GET["action_param"]);
|
$action_param = db_escape_string($_GET["action_param"]);
|
||||||
|
$action_param_label = db_escape_string($_GET["action_param_label"]);
|
||||||
$enabled = checkbox_to_sql_bool(db_escape_string($_GET["enabled"]));
|
$enabled = checkbox_to_sql_bool(db_escape_string($_GET["enabled"]));
|
||||||
$inverse = checkbox_to_sql_bool(db_escape_string($_GET["inverse"]));
|
$inverse = checkbox_to_sql_bool(db_escape_string($_GET["inverse"]));
|
||||||
|
|
||||||
|
@ -181,7 +191,14 @@
|
||||||
} else {
|
} else {
|
||||||
$feed_id = sprintf("'%s'", db_escape_string($feed_id));
|
$feed_id = sprintf("'%s'", db_escape_string($feed_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* When processing 'assign label' filters, action_param_label dropbox
|
||||||
|
* overrides action_param */
|
||||||
|
|
||||||
|
if ($action_id == 7) {
|
||||||
|
$action_param = $action_param_label;
|
||||||
|
}
|
||||||
|
|
||||||
$result = db_query($link, "UPDATE ttrss_filters SET
|
$result = db_query($link, "UPDATE ttrss_filters SET
|
||||||
reg_exp = '$reg_exp',
|
reg_exp = '$reg_exp',
|
||||||
feed_id = $feed_id,
|
feed_id = $feed_id,
|
||||||
|
@ -475,4 +492,24 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function print_label_select($link, $name, $value, $style = "") {
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT caption FROM ttrss_labels2
|
||||||
|
WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY caption");
|
||||||
|
|
||||||
|
print "<select name=\"$name\" style=\"$style\">";
|
||||||
|
|
||||||
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
|
$issel = ($line["caption"] == $value) ? "selected" : "";
|
||||||
|
|
||||||
|
print "<option $issel>" . $line["caption"] . "</option>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</select>";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,214 +1,78 @@
|
||||||
<?php
|
<?php
|
||||||
// We need to accept raw SQL data in label queries, so not everything is escaped
|
|
||||||
// here, this is by design. If you don't like it, disable labels
|
|
||||||
// altogether with GLOBAL_ENABLE_LABELS = false
|
|
||||||
|
|
||||||
function module_pref_labels($link) {
|
function module_pref_labels($link) {
|
||||||
if (!GLOBAL_ENABLE_LABELS) {
|
|
||||||
|
|
||||||
print __("Sorry, labels have been administratively disabled for this installation. Please contact instance owner or edit configuration file to enable this functionality.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$subop = $_GET["subop"];
|
$subop = $_GET["subop"];
|
||||||
|
|
||||||
if ($subop == "edit") {
|
if ($subop == "save") {
|
||||||
|
|
||||||
$label_id = db_escape_string($_GET["id"]);
|
$id = db_escape_string($_REQUEST["id"]);
|
||||||
|
$caption = trim(db_escape_string($_REQUEST["value"]));
|
||||||
|
|
||||||
$result = db_query($link, "SELECT sql_exp,description FROM ttrss_labels WHERE
|
db_query($link, "BEGIN");
|
||||||
owner_uid = ".$_SESSION["uid"]." AND id = '$label_id' ORDER by description");
|
|
||||||
|
|
||||||
$line = db_fetch_assoc($result);
|
$result = db_query($link, "SELECT caption FROM ttrss_labels2
|
||||||
|
WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
|
||||||
|
|
||||||
$sql_exp = htmlspecialchars($line["sql_exp"]);
|
if (db_num_rows($result) != 0) {
|
||||||
$description = htmlspecialchars($line["description"]);
|
$old_caption = db_fetch_result($result, 0, "caption");
|
||||||
|
|
||||||
print "<div id=\"infoBoxTitle\">Label Editor</div>";
|
$result = db_query($link, "SELECT id FROM ttrss_labels2
|
||||||
print "<div class=\"infoBoxContents\">";
|
WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
|
||||||
|
|
||||||
print "<form id=\"label_edit_form\" onsubmit='return false'>";
|
if (db_num_rows($result) == 0) {
|
||||||
|
if ($caption) {
|
||||||
|
$result = db_query($link, "UPDATE ttrss_labels2 SET
|
||||||
|
caption = '$caption' WHERE id = '$id' AND
|
||||||
|
owner_uid = " . $_SESSION["uid"]);
|
||||||
|
|
||||||
print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
|
/* Update filters that reference label being renamed */
|
||||||
print "<input type=\"hidden\" name=\"id\" value=\"$label_id\">";
|
|
||||||
print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
|
|
||||||
|
|
||||||
print "<div class=\"dlgSec\">".__("Caption")."</div>";
|
db_query($link, "UPDATE ttrss_filters SET
|
||||||
|
action_param = '$caption' WHERE action_param = '$old_caption'
|
||||||
|
AND action_id = 7
|
||||||
|
AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
|
||||||
print "<div class=\"dlgSecCont\">";
|
print $caption;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print $old_caption;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print "<input onkeypress=\"return filterCR(event, labelEditSave)\"
|
db_query($link, "COMMIT");
|
||||||
onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
|
|
||||||
onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
|
|
||||||
name=\"description\" size=\"30\" value=\"$description\">";
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
print "<div class=\"dlgSec\">".__("Match SQL")."</div>";
|
|
||||||
|
|
||||||
print "<div class=\"dlgSecCont\">";
|
|
||||||
|
|
||||||
print "<textarea onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
|
|
||||||
rows=\"6\" name=\"sql_exp\" class=\"labelSQL\" cols=\"50\">$sql_exp</textarea>";
|
|
||||||
|
|
||||||
print "<br/>";
|
|
||||||
|
|
||||||
print_label_dlg_common_examples();
|
|
||||||
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
|
|
||||||
print "<div style=\"display : none\" id=\"label_test_result\"></div>";
|
|
||||||
|
|
||||||
print "<div class=\"dlgButtons\">";
|
|
||||||
|
|
||||||
print "<div style='float : left'>";
|
|
||||||
print "<input type=\"submit\"
|
|
||||||
class=\"button\" onclick=\"return displayHelpInfobox(1)\"
|
|
||||||
value=\"".__('Help')."\"> ";
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
$is_disabled = (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== FALSE) ? "disabled" : "";
|
|
||||||
|
|
||||||
print "<input $is_disabled type=\"submit\" onclick=\"return labelTest()\" value=\"Test\">
|
|
||||||
";
|
|
||||||
|
|
||||||
print "<input type=\"submit\"
|
|
||||||
id=\"infobox_submit\"
|
|
||||||
class=\"button\" onclick=\"return labelEditSave()\"
|
|
||||||
value=\"Save\"> ";
|
|
||||||
|
|
||||||
print "<input class=\"button\"
|
|
||||||
type=\"submit\" onclick=\"return labelEditCancel()\"
|
|
||||||
value=\"Cancel\">";
|
|
||||||
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "test") {
|
|
||||||
|
|
||||||
// no escaping here on purpose
|
|
||||||
$expr = trim($_GET["expr"]);
|
|
||||||
$descr = db_escape_string(trim($_GET["descr"]));
|
|
||||||
|
|
||||||
$expr = str_replace(";", "", $expr);
|
|
||||||
|
|
||||||
if (!$expr) {
|
|
||||||
print "<p>".__("Error: SQL expression is blank.")."</p>";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<div>";
|
|
||||||
|
|
||||||
error_reporting(0);
|
|
||||||
|
|
||||||
|
|
||||||
$result = db_query($link,
|
|
||||||
"SELECT count(ttrss_entries.id) AS num_matches
|
|
||||||
FROM ttrss_entries,ttrss_user_entries,ttrss_feeds
|
|
||||||
WHERE ($expr) AND
|
|
||||||
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
|
||||||
ttrss_user_entries.feed_id = ttrss_feeds.id AND
|
|
||||||
ttrss_user_entries.owner_uid = " . $_SESSION["uid"], false);
|
|
||||||
|
|
||||||
error_reporting (DEFAULT_ERROR_LEVEL);
|
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
print "<div class=\"labelTestError\">" . db_last_error($link) . "</div>";
|
|
||||||
print "</div>";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$num_matches = db_fetch_result($result, 0, "num_matches");;
|
|
||||||
|
|
||||||
if ($num_matches > 0) {
|
|
||||||
|
|
||||||
if ($num_matches > 10) {
|
|
||||||
$showing_msg = ", showing first 10";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<p>Query returned <b>$num_matches</b> matches$showing_msg:</p>";
|
|
||||||
|
|
||||||
$result = db_query($link,
|
|
||||||
"SELECT ttrss_entries.title,
|
|
||||||
(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
|
|
||||||
FROM ttrss_entries,ttrss_user_entries,ttrss_feeds
|
|
||||||
WHERE ($expr) AND
|
|
||||||
ttrss_user_entries.ref_id = ttrss_entries.id
|
|
||||||
AND ttrss_user_entries.feed_id = ttrss_feeds.id
|
|
||||||
AND ttrss_user_entries.owner_uid = " . $_SESSION["uid"] . "
|
|
||||||
ORDER BY date_entered LIMIT 10", false);
|
|
||||||
|
|
||||||
print "<ul class=\"labelTestResults\">";
|
|
||||||
|
|
||||||
$row_class = "even";
|
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
|
||||||
$row_class = toggleEvenOdd($row_class);
|
|
||||||
|
|
||||||
print "<li class=\"$row_class\">".$line["title"].
|
|
||||||
" <span class=\"insensitive\">(".$line["feed_title"].")</span></li>";
|
|
||||||
}
|
|
||||||
print "</ul>";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print "<p>Query didn't return any matches.</p>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($subop == "editSave") {
|
|
||||||
|
|
||||||
$sql_exp = db_escape_string(trim($_GET["sql_exp"]));
|
|
||||||
$descr = db_escape_string(trim($_GET["description"]));
|
|
||||||
$label_id = db_escape_string($_GET["id"]);
|
|
||||||
|
|
||||||
$sql_exp = str_replace(";", "", $sql_exp);
|
|
||||||
|
|
||||||
$result = db_query($link, "UPDATE ttrss_labels SET
|
|
||||||
sql_exp = '$sql_exp',
|
|
||||||
description = '$descr'
|
|
||||||
WHERE id = '$label_id'");
|
|
||||||
|
|
||||||
if (db_affected_rows($link, $result) != 0) {
|
|
||||||
print_notice(T_sprintf("Saved label <b>%s</b>", htmlspecialchars($descr)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($subop == "remove") {
|
if ($subop == "remove") {
|
||||||
|
|
||||||
if (!WEB_DEMO_MODE) {
|
$ids = split(",", db_escape_string($_GET["ids"]));
|
||||||
|
|
||||||
$ids = split(",", db_escape_string($_GET["ids"]));
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'");
|
db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
|
||||||
|
AND owner_uid = " . $_SESSION["uid"]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "add") {
|
if ($subop == "add") {
|
||||||
|
|
||||||
$sql_exp = db_escape_string(trim($_GET["sql_exp"]));
|
$caption = db_escape_string($_GET["caption"]);
|
||||||
$description = db_escape_string($_GET["description"]);
|
|
||||||
|
|
||||||
$sql_exp = str_replace(";", "", $sql_exp);
|
if ($caption) {
|
||||||
|
|
||||||
if (!$sql_exp || !$description) return;
|
$result = db_query($link, "SELECT id FROM ttrss_labels2
|
||||||
|
WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
|
||||||
|
|
||||||
$result = db_query($link,
|
if (db_num_rows($result) == 0) {
|
||||||
"INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
|
|
||||||
VALUES ('$sql_exp', '$description', '".$_SESSION["uid"]."')");
|
|
||||||
|
|
||||||
if (db_affected_rows($link, $result) != 0) {
|
$result = db_query($link,
|
||||||
print T_sprintf("Created label <b>%s</b>", htmlspecialchars($description));
|
"INSERT INTO ttrss_labels2 (caption,owner_uid)
|
||||||
|
VALUES ('$caption', '".$_SESSION["uid"]."')");
|
||||||
|
|
||||||
|
if (db_affected_rows($link, $result) != 0) {
|
||||||
|
print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -219,7 +83,7 @@
|
||||||
$sort = db_escape_string($_GET["sort"]);
|
$sort = db_escape_string($_GET["sort"]);
|
||||||
|
|
||||||
if (!$sort || $sort == "undefined") {
|
if (!$sort || $sort == "undefined") {
|
||||||
$sort = "description";
|
$sort = "caption";
|
||||||
}
|
}
|
||||||
|
|
||||||
$label_search = db_escape_string($_GET["search"]);
|
$label_search = db_escape_string($_GET["search"]);
|
||||||
|
@ -237,28 +101,25 @@
|
||||||
onchange=\"javascript:updateLabelList()\" value=\"$label_search\">
|
onchange=\"javascript:updateLabelList()\" value=\"$label_search\">
|
||||||
<input type=\"submit\" class=\"button\"
|
<input type=\"submit\" class=\"button\"
|
||||||
onclick=\"javascript:updateLabelList()\" value=\"".__('Search')."\">
|
onclick=\"javascript:updateLabelList()\" value=\"".__('Search')."\">
|
||||||
<p><a class='helpLinkPic' href=\"javascript:displayHelpInfobox(1)\">
|
|
||||||
<img src='images/sign_quest.gif'></a></p>
|
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
print "<div class=\"prefGenericAddBox\">";
|
print "<div class=\"prefGenericAddBox\">";
|
||||||
|
|
||||||
print"<input type=\"submit\" class=\"button\"
|
print"<input type=\"submit\" class=\"button\"
|
||||||
id=\"label_create_btn\"
|
id=\"label_create_btn\"
|
||||||
onclick=\"return displayDlg('quickAddLabel', false)\"
|
onclick=\"return addLabel()\"
|
||||||
value=\"".__('Create label')."\"></div>";
|
value=\"".__('Create label')."\"></div>";
|
||||||
|
|
||||||
if ($label_search) {
|
if ($label_search) {
|
||||||
$label_search_query = "(sql_exp LIKE '%$label_search%' OR
|
$label_search_query = "caption LIKE '%$label_search%' AND";
|
||||||
description LIKE '%$label_search%') AND";
|
|
||||||
} else {
|
} else {
|
||||||
$label_search_query = "";
|
$label_search_query = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
$result = db_query($link, "SELECT
|
||||||
id,sql_exp,description
|
id,caption
|
||||||
FROM
|
FROM
|
||||||
ttrss_labels
|
ttrss_labels2
|
||||||
WHERE
|
WHERE
|
||||||
$label_search_query
|
$label_search_query
|
||||||
owner_uid = ".$_SESSION["uid"]."
|
owner_uid = ".$_SESSION["uid"]."
|
||||||
|
@ -279,8 +140,7 @@
|
||||||
|
|
||||||
print "<tr class=\"title\">
|
print "<tr class=\"title\">
|
||||||
<td width=\"5%\"> </td>
|
<td width=\"5%\"> </td>
|
||||||
<td width=\"30%\"><a href=\"javascript:updateLabelList('description')\">".__('Caption')."</a></td>
|
<td width=\"95%\"><a href=\"javascript:updateLabelList('description')\">".__('Caption')."</a></td>
|
||||||
<td width=\"\"><a href=\"javascript:updateLabelList('sql_exp')\">".__('SQL Expression')."</a>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
|
@ -291,29 +151,18 @@
|
||||||
$class = ($lnum % 2) ? "even" : "odd";
|
$class = ($lnum % 2) ? "even" : "odd";
|
||||||
|
|
||||||
$label_id = $line["id"];
|
$label_id = $line["id"];
|
||||||
$edit_label_id = $_GET["id"];
|
$this_row_id = "id=\"LILRR-$label_id\"";
|
||||||
|
|
||||||
if ($subop == "edit" && $label_id != $edit_label_id) {
|
|
||||||
$class .= "Grayed";
|
|
||||||
$this_row_id = "";
|
|
||||||
} else {
|
|
||||||
$this_row_id = "id=\"LILRR-$label_id\"";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<tr class=\"$class\" $this_row_id>";
|
print "<tr class=\"$class\" $this_row_id>";
|
||||||
|
|
||||||
$line["sql_exp"] = htmlspecialchars($line["sql_exp"]);
|
$line["caption"] = htmlspecialchars($line["caption"]);
|
||||||
$line["description"] = htmlspecialchars($line["description"]);
|
|
||||||
|
|
||||||
if (!$line["description"]) $line["description"] = __("[No caption]");
|
print "<td align='center'><input
|
||||||
|
onclick='toggleSelectPrefRow(this, \"label\");'
|
||||||
$onclick = "onclick='editLabel($label_id)' title='".__('Click to edit')."'";
|
|
||||||
|
|
||||||
print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"label\");'
|
|
||||||
type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
|
type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
|
||||||
|
|
||||||
print "<td $onclick>" . $line["description"] . "</td>";
|
print "<td><span id=\"LILT-".$line["id"]."\">" . $line["caption"] .
|
||||||
print "<td $onclick>" . $line["sql_exp"] . "</td>";
|
"</span></td>";
|
||||||
|
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|
||||||
|
@ -323,11 +172,9 @@
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
print "<p id=\"labelOpToolbar\">";
|
print "<p id=\"labelOpToolbar\">";
|
||||||
|
|
||||||
print "<input type=\"submit\" class=\"button\" disabled=\"true\"
|
print "<input type=\"submit\" class=\"button\" disabled=\"true\"
|
||||||
onclick=\"javascript:editSelectedLabel()\" value=\"".__('Edit')."\">
|
|
||||||
<input type=\"submit\" class=\"button\" disabled=\"true\"
|
|
||||||
onclick=\"javascript:removeSelectedLabels()\" value=\"".__('Remove')."\">";
|
onclick=\"javascript:removeSelectedLabels()\" value=\"".__('Remove')."\">";
|
||||||
|
print "</p>";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
print "<p>";
|
print "<p>";
|
||||||
|
|
72
prefs.js
72
prefs.js
|
@ -135,28 +135,36 @@ function filterlist_callback() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function labellist_callback() {
|
function labellist_callback() {
|
||||||
var container = document.getElementById('prefContent');
|
|
||||||
if (xmlhttp.readyState == 4) {
|
try {
|
||||||
closeInfoBox();
|
|
||||||
container.innerHTML=xmlhttp.responseText;
|
var container = document.getElementById('prefContent');
|
||||||
if (active_label) {
|
if (xmlhttp.readyState == 4) {
|
||||||
var row = document.getElementById("LILRR-" + active_label);
|
closeInfoBox();
|
||||||
if (row) {
|
container.innerHTML=xmlhttp.responseText;
|
||||||
if (!row.className.match("Selected")) {
|
|
||||||
row.className = row.className + "Selected";
|
if (document.getElementById("prefLabelList")) {
|
||||||
}
|
var elems = document.getElementById("prefLabelList").getElementsByTagName("SPAN");
|
||||||
|
|
||||||
|
for (var i = 0; i < elems.length; i++) {
|
||||||
|
if (elems[i].id && elems[i].id.match("LILT-")) {
|
||||||
|
|
||||||
|
var id = elems[i].id.replace("LILT-", "");
|
||||||
|
new Ajax.InPlaceEditor(elems[i],
|
||||||
|
'backend.php?op=pref-labels&subop=save&id=' + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var checkbox = document.getElementById("LICHK-" + active_label);
|
|
||||||
|
if (typeof correctPNG != 'undefined') {
|
||||||
if (checkbox) {
|
correctPNG();
|
||||||
checkbox.checked = true;
|
|
||||||
}
|
}
|
||||||
|
notify("");
|
||||||
|
remove_splash();
|
||||||
}
|
}
|
||||||
if (typeof correctPNG != 'undefined') {
|
|
||||||
correctPNG();
|
} catch (e) {
|
||||||
}
|
exception_error("labellist_callback", e);
|
||||||
notify("");
|
|
||||||
remove_splash();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,34 +312,32 @@ function updateUsersList(sort_key) {
|
||||||
|
|
||||||
function addLabel() {
|
function addLabel() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
if (!xmlhttp_ready(xmlhttp)) {
|
if (!xmlhttp_ready(xmlhttp)) {
|
||||||
printLockingError();
|
printLockingError();
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var form = document.forms['label_edit_form'];
|
var caption = prompt(__("Please enter label caption:"), "");
|
||||||
|
|
||||||
var sql_exp = form.sql_exp.value;
|
if (caption == "") {
|
||||||
var description = form.description.value;
|
|
||||||
|
|
||||||
if (sql_exp == "") {
|
|
||||||
alert(__("Can't create label: missing SQL expression."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (description == "") {
|
|
||||||
alert(__("Can't create label: missing caption."));
|
alert(__("Can't create label: missing caption."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var query = Form.serialize("label_edit_form");
|
|
||||||
|
|
||||||
// we can be called from some other tab
|
// we can be called from some other tab
|
||||||
active_tab = "labelConfig";
|
active_tab = "labelConfig";
|
||||||
|
|
||||||
|
var query = "caption=" + param_escape(caption);
|
||||||
|
|
||||||
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);
|
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);
|
||||||
xmlhttp.onreadystatechange=infobox_submit_callback;
|
xmlhttp.onreadystatechange=infobox_submit_callback;
|
||||||
xmlhttp.send(null);
|
xmlhttp.send(null);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("addLabel", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFeed() {
|
function addFeed() {
|
||||||
|
@ -1834,10 +1840,10 @@ function pref_hotkey_handler(e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycode == 76) { // l
|
/* if (keycode == 76) { // l
|
||||||
displayDlg("quickAddLabel");
|
displayDlg("quickAddLabel");
|
||||||
return false;
|
return false;
|
||||||
}
|
} */
|
||||||
|
|
||||||
if (keycode == 85) { // u
|
if (keycode == 85) { // u
|
||||||
// no-op
|
// no-op
|
||||||
|
|
|
@ -140,10 +140,8 @@ window.onload = init;
|
||||||
onclick="selectTab('pubItems')"><?php echo __('Published Articles') ?></div> -->
|
onclick="selectTab('pubItems')"><?php echo __('Published Articles') ?></div> -->
|
||||||
<div id="filterConfigTab" class="prefsTab"
|
<div id="filterConfigTab" class="prefsTab"
|
||||||
onclick="selectTab('filterConfig')"><?php echo __('Content Filtering') ?></div>
|
onclick="selectTab('filterConfig')"><?php echo __('Content Filtering') ?></div>
|
||||||
<?php if (get_pref($link, 'ENABLE_LABELS')) { ?>
|
|
||||||
<div id="labelConfigTab" class="prefsTab"
|
<div id="labelConfigTab" class="prefsTab"
|
||||||
onclick="selectTab('labelConfig')"><?php echo __('Label Editor') ?></div>
|
onclick="selectTab('labelConfig')"><?php echo __('Label Editor') ?></div>
|
||||||
<?php } ?>
|
|
||||||
<?php if ($_SESSION["access_level"] >= 10) { ?>
|
<?php if ($_SESSION["access_level"] >= 10) { ?>
|
||||||
<div id="userConfigTab" class="prefsTab"
|
<div id="userConfigTab" class="prefsTab"
|
||||||
onclick="selectTab('userConfig')"><?php echo __('User Manager') ?></div>
|
onclick="selectTab('userConfig')"><?php echo __('User Manager') ?></div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
require_once "functions.php";
|
require_once "functions.php";
|
||||||
|
|
||||||
define('EXPECTED_CONFIG_VERSION', 17);
|
define('EXPECTED_CONFIG_VERSION', 17);
|
||||||
define('SCHEMA_VERSION', 50);
|
define('SCHEMA_VERSION', 51);
|
||||||
|
|
||||||
if (!file_exists("config.php")) {
|
if (!file_exists("config.php")) {
|
||||||
print __("<b>Fatal Error</b>: You forgot to copy
|
print __("<b>Fatal Error</b>: You forgot to copy
|
||||||
|
|
|
@ -189,6 +189,9 @@ insert into ttrss_filter_actions (id,name,description) values (5, 'publish',
|
||||||
insert into ttrss_filter_actions (id,name,description) values (6, 'score',
|
insert into ttrss_filter_actions (id,name,description) values (6, 'score',
|
||||||
'Modify score');
|
'Modify score');
|
||||||
|
|
||||||
|
insert into ttrss_filter_actions (id,name,description) values (7, 'label',
|
||||||
|
'Assign label');
|
||||||
|
|
||||||
create table ttrss_filters (id integer not null primary key auto_increment,
|
create table ttrss_filters (id integer not null primary key auto_increment,
|
||||||
owner_uid integer not null,
|
owner_uid integer not null,
|
||||||
feed_id integer default null,
|
feed_id integer default null,
|
||||||
|
@ -232,7 +235,7 @@ create table ttrss_tags (id integer primary key auto_increment,
|
||||||
|
|
||||||
create table ttrss_version (schema_version int not null) TYPE=InnoDB;
|
create table ttrss_version (schema_version int not null) TYPE=InnoDB;
|
||||||
|
|
||||||
insert into ttrss_version values (50);
|
insert into ttrss_version values (51);
|
||||||
|
|
||||||
create table ttrss_enclosures (id serial not null primary key,
|
create table ttrss_enclosures (id serial not null primary key,
|
||||||
content_url text not null,
|
content_url text not null,
|
||||||
|
@ -389,4 +392,16 @@ create table ttrss_feedbrowser_cache (
|
||||||
feed_url text not null,
|
feed_url text not null,
|
||||||
subscribers integer not null);
|
subscribers integer not null);
|
||||||
|
|
||||||
|
create table ttrss_labels2 (id integer not null primary key auto_increment,
|
||||||
|
owner_uid integer not null,
|
||||||
|
caption varchar(250) not null,
|
||||||
|
foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE
|
||||||
|
) TYPE=InnoDB;
|
||||||
|
|
||||||
|
create table ttrss_user_labels2 (label_id integer not null,
|
||||||
|
article_id integer not null,
|
||||||
|
foreign key (label_id) references ttrss_labels2(id) ON DELETE CASCADE,
|
||||||
|
foreign key (article_id) references ttrss_entries(id) ON DELETE CASCADE
|
||||||
|
) TYPE=InnoDB;
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
drop table ttrss_user_labels2;
|
||||||
|
drop table ttrss_labels2;
|
||||||
drop table ttrss_feedbrowser_cache;
|
drop table ttrss_feedbrowser_cache;
|
||||||
drop table ttrss_version;
|
drop table ttrss_version;
|
||||||
drop table ttrss_labels;
|
drop table ttrss_labels;
|
||||||
|
@ -175,6 +177,9 @@ insert into ttrss_filter_actions (id,name,description) values (5, 'publish',
|
||||||
insert into ttrss_filter_actions (id,name,description) values (6, 'score',
|
insert into ttrss_filter_actions (id,name,description) values (6, 'score',
|
||||||
'Modify score');
|
'Modify score');
|
||||||
|
|
||||||
|
insert into ttrss_filter_actions (id,name,description) values (7, 'label',
|
||||||
|
'Assign label');
|
||||||
|
|
||||||
create table ttrss_filters (id serial not null primary key,
|
create table ttrss_filters (id serial not null primary key,
|
||||||
owner_uid integer not null references ttrss_users(id) on delete cascade,
|
owner_uid integer not null references ttrss_users(id) on delete cascade,
|
||||||
feed_id integer references ttrss_feeds(id) on delete cascade default null,
|
feed_id integer references ttrss_feeds(id) on delete cascade default null,
|
||||||
|
@ -208,7 +213,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
|
||||||
|
|
||||||
create table ttrss_version (schema_version int not null);
|
create table ttrss_version (schema_version int not null);
|
||||||
|
|
||||||
insert into ttrss_version values (50);
|
insert into ttrss_version values (51);
|
||||||
|
|
||||||
create table ttrss_enclosures (id serial not null primary key,
|
create table ttrss_enclosures (id serial not null primary key,
|
||||||
content_url text not null,
|
content_url text not null,
|
||||||
|
@ -358,4 +363,14 @@ create table ttrss_feedbrowser_cache (
|
||||||
feed_url text not null primary key,
|
feed_url text not null primary key,
|
||||||
subscribers integer not null);
|
subscribers integer not null);
|
||||||
|
|
||||||
|
create table ttrss_labels2 (id serial not null primary key,
|
||||||
|
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
||||||
|
caption varchar(250) not null
|
||||||
|
);
|
||||||
|
|
||||||
|
create table ttrss_user_labels2 (
|
||||||
|
label_id integer not null references ttrss_labels2(id) ON DELETE CASCADE,
|
||||||
|
article_id integer not null references ttrss_entries(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
create table ttrss_labels2 (id integer not null primary key auto_increment,
|
||||||
|
owner_uid integer not null,
|
||||||
|
caption varchar(250) not null,
|
||||||
|
foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE
|
||||||
|
) TYPE=InnoDB;
|
||||||
|
|
||||||
|
create table ttrss_user_labels2 (label_id integer not null,
|
||||||
|
article_id integer not null,
|
||||||
|
foreign key (label_id) references ttrss_labels2(id) ON DELETE CASCADE,
|
||||||
|
foreign key (article_id) references ttrss_entries(id) ON DELETE CASCADE
|
||||||
|
) TYPE=InnoDB;
|
||||||
|
|
||||||
|
insert into ttrss_filter_actions (id,name,description) values (7, 'label',
|
||||||
|
'Assign label');
|
||||||
|
|
||||||
|
update ttrss_version set schema_version = 51;
|
|
@ -0,0 +1,18 @@
|
||||||
|
begin;
|
||||||
|
|
||||||
|
create table ttrss_labels2 (id serial not null primary key,
|
||||||
|
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
||||||
|
caption varchar(250) not null
|
||||||
|
);
|
||||||
|
|
||||||
|
create table ttrss_user_labels2 (
|
||||||
|
label_id integer not null references ttrss_labels2(id) ON DELETE CASCADE,
|
||||||
|
article_id integer not null references ttrss_entries(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
insert into ttrss_filter_actions (id,name,description) values (7, 'label',
|
||||||
|
'Assign label');
|
||||||
|
|
||||||
|
update ttrss_version set schema_version = 51;
|
||||||
|
|
||||||
|
commit;
|
25
viewfeed.js
25
viewfeed.js
|
@ -1159,31 +1159,6 @@ function catchupSelection() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function labelFromSearch(search, search_mode, match_on, feed_id, is_cat) {
|
|
||||||
|
|
||||||
if (!xmlhttp_ready(xmlhttp_rpc)) {
|
|
||||||
printLockingError();
|
|
||||||
}
|
|
||||||
|
|
||||||
var title = prompt(__("Please enter label title:"), "");
|
|
||||||
|
|
||||||
if (title) {
|
|
||||||
|
|
||||||
var query = "backend.php?op=labelFromSearch&search=" + param_escape(search) +
|
|
||||||
"&smode=" + param_escape(search_mode) + "&match=" + param_escape(match_on) +
|
|
||||||
"&feed=" + param_escape(feed_id) + "&is_cat=" + param_escape(is_cat) +
|
|
||||||
"&title=" + param_escape(title);
|
|
||||||
|
|
||||||
debug("LFS: " + query);
|
|
||||||
|
|
||||||
new Ajax.Request(query, {
|
|
||||||
onComplete: function(transport) {
|
|
||||||
dlg_frefresh_callback(transport);
|
|
||||||
} });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function editArticleTags(id, feed_id, cdm_enabled) {
|
function editArticleTags(id, feed_id, cdm_enabled) {
|
||||||
_tag_active_post_id = id;
|
_tag_active_post_id = id;
|
||||||
_tag_active_feed_id = feed_id;
|
_tag_active_feed_id = feed_id;
|
||||||
|
|
Loading…
Reference in New Issue