allow adding/removing labels from frontend
This commit is contained in:
parent
b2531a28a6
commit
1380f8eed4
|
@ -6102,4 +6102,29 @@
|
||||||
(label_id, article_id) VALUES ('$label_id', '$id')");
|
(label_id, article_id) VALUES ('$label_id', '$id')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function label_remove($link, $id, $owner_uid) {
|
||||||
|
|
||||||
|
db_query($link, "BEGIN");
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT caption FROM ttrss_labels2
|
||||||
|
WHERE id = '$id'");
|
||||||
|
|
||||||
|
$caption = db_fetch_result($result, 0, "caption");
|
||||||
|
|
||||||
|
$result = db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
|
||||||
|
AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
|
||||||
|
if (db_affected_rows($link, $result) != 0 && $caption) {
|
||||||
|
|
||||||
|
/* Disable filters that reference label being removed */
|
||||||
|
|
||||||
|
db_query($link, "UPDATE ttrss_filters SET
|
||||||
|
enabled = false WHERE action_param = '$caption'
|
||||||
|
AND action_id = 7
|
||||||
|
AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
db_query($link, "COMMIT");
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -717,6 +717,8 @@
|
||||||
if (file_exists($icons_dir . "/$id.ico")) {
|
if (file_exists($icons_dir . "/$id.ico")) {
|
||||||
unlink($icons_dir . "/$id.ico");
|
unlink($icons_dir . "/$id.ico");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
label_remove($link, -11-$id, $_SESSION["uid"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,30 +50,10 @@
|
||||||
|
|
||||||
$ids = split(",", db_escape_string($_GET["ids"]));
|
$ids = split(",", db_escape_string($_GET["ids"]));
|
||||||
|
|
||||||
db_query($link, "BEGIN");
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$result = db_query($link, "SELECT caption FROM ttrss_labels2
|
label_remove($link, $id, $_SESSION["uid"]);
|
||||||
WHERE id = '$id'");
|
|
||||||
|
|
||||||
$caption = db_fetch_result($result, 0, "caption");
|
|
||||||
|
|
||||||
$result = db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
|
|
||||||
AND owner_uid = " . $_SESSION["uid"]);
|
|
||||||
|
|
||||||
if (db_affected_rows($link, $result) != 0 && $caption) {
|
|
||||||
|
|
||||||
/* Disable filters that reference label being removed */
|
|
||||||
|
|
||||||
db_query($link, "UPDATE ttrss_filters SET
|
|
||||||
enabled = false WHERE action_param = '$caption'
|
|
||||||
AND action_id = 7
|
|
||||||
AND owner_uid = " . $_SESSION["uid"]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db_query($link, "COMMIT");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "add") {
|
if ($subop == "add") {
|
||||||
|
|
41
tt-rss.js
41
tt-rss.js
|
@ -562,11 +562,6 @@ function quickMenuGo(opid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actid <= 0) {
|
|
||||||
alert(__("You can't unsubscribe from this kind of feed."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!actid) {
|
if (!actid) {
|
||||||
alert(__("Please select some feed first."));
|
alert(__("Please select some feed first."));
|
||||||
return;
|
return;
|
||||||
|
@ -627,6 +622,10 @@ function quickMenuGo(opid) {
|
||||||
displayDlg("quickAddFilter", getActiveFeedId());
|
displayDlg("quickAddFilter", getActiveFeedId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opid == "qmcAddLabel") {
|
||||||
|
addLabel();
|
||||||
|
}
|
||||||
|
|
||||||
if (opid == "qmcRescoreFeed") {
|
if (opid == "qmcRescoreFeed") {
|
||||||
rescoreCurrentFeed();
|
rescoreCurrentFeed();
|
||||||
}
|
}
|
||||||
|
@ -1391,3 +1390,35 @@ function hotkey_handler(e) {
|
||||||
function feedsSortByUnread() {
|
function feedsSortByUnread() {
|
||||||
return feeds_sort_by_unread;
|
return feeds_sort_by_unread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addLabel() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
var caption = prompt(__("Please enter label caption:"), "");
|
||||||
|
|
||||||
|
if (caption != undefined) {
|
||||||
|
|
||||||
|
if (caption == "") {
|
||||||
|
alert(__("Can't create label: missing caption."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var query = "backend.php?op=pref-labels&subop=add&caption=" +
|
||||||
|
param_escape(caption);
|
||||||
|
|
||||||
|
notify_progress("Loading, please wait...", true);
|
||||||
|
|
||||||
|
new Ajax.Request(query, {
|
||||||
|
onComplete: function(transport) {
|
||||||
|
updateFeedList();
|
||||||
|
} });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("addLabel", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,8 @@ window.onload = init;
|
||||||
<option value="qmcShowOnlyUnread"><?php echo __(' (Un)hide read feeds') ?></option>
|
<option value="qmcShowOnlyUnread"><?php echo __(' (Un)hide read feeds') ?></option>
|
||||||
<option disabled="disabled">--------</option>
|
<option disabled="disabled">--------</option>
|
||||||
<option style="color : #5050aa" disabled="disabled"><?php echo __('Other actions:') ?></option>
|
<option style="color : #5050aa" disabled="disabled"><?php echo __('Other actions:') ?></option>
|
||||||
|
|
||||||
|
<option value="qmcAddLabel"><?php echo __(' Create label') ?></option>
|
||||||
<option value="qmcAddFilter"><?php echo __(' Create filter') ?></option>
|
<option value="qmcAddFilter"><?php echo __(' Create filter') ?></option>
|
||||||
<option value="qmcResetUI"><?php echo __(' Reset UI layout') ?></option>
|
<option value="qmcResetUI"><?php echo __(' Reset UI layout') ?></option>
|
||||||
<option value="qmcResetCats"><?php echo __(' Reset category order') ?></option>
|
<option value="qmcResetCats"><?php echo __(' Reset category order') ?></option>
|
||||||
|
|
Loading…
Reference in New Issue