summaryrefslogtreecommitdiff
path: root/include/labels.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-05-04 15:57:40 +0300
committerAndrew Dolgov <[email protected]>2017-05-04 15:57:40 +0300
commit7c9b5a3fe40a641af1cb6003b03b2352576a0c4b (patch)
treeaee154f7437c945c18074a2a158a65845ef115f2 /include/labels.php
parentc2f0f24e4c4577944b563f3c0af92a8ed89b8e61 (diff)
move label stuff to Labels class
fix some unresolved functions
Diffstat (limited to 'include/labels.php')
-rw-r--r--include/labels.php161
1 files changed, 0 insertions, 161 deletions
diff --git a/include/labels.php b/include/labels.php
deleted file mode 100644
index f39f092db..000000000
--- a/include/labels.php
+++ /dev/null
@@ -1,161 +0,0 @@
-<?php
- function label_to_feed_id($label) {
- return LABEL_BASE_INDEX - 1 - abs($label);
- }
-
- function feed_to_label_id($feed) {
- return LABEL_BASE_INDEX - 1 + abs($feed);
- }
-
- function label_find_id($label, $owner_uid) {
- $result = db_query(
- "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_find_caption($label, $owner_uid) {
- $result = db_query(
- "SELECT caption FROM ttrss_labels2 WHERE id = '$label'
- AND owner_uid = '$owner_uid' LIMIT 1");
-
- if (db_num_rows($result) == 1) {
- return db_fetch_result($result, 0, "caption");
- } else {
- return "";
- }
- }
-
- function get_all_labels($owner_uid) {
- $rv = array();
-
- $result = db_query("SELECT fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = " . $owner_uid);
-
- while ($line = db_fetch_assoc($result)) {
- array_push($rv, $line);
- }
-
- return $rv;
- }
-
- function label_update_cache($owner_uid, $id, $labels = false, $force = false) {
-
- if ($force)
- label_clear_cache($id);
-
- if (!$labels)
- $labels = get_article_labels($id);
-
- $labels = db_escape_string(json_encode($labels));
-
- db_query("UPDATE ttrss_user_entries SET
- label_cache = '$labels' WHERE ref_id = '$id' AND owner_uid = '$owner_uid'");
-
- }
-
- function label_clear_cache($id) {
-
- db_query("UPDATE ttrss_user_entries SET
- label_cache = '' WHERE ref_id = '$id'");
-
- }
-
- function label_remove_article($id, $label, $owner_uid) {
-
- $label_id = label_find_id($label, $owner_uid);
-
- if (!$label_id) return;
-
- db_query(
- "DELETE FROM ttrss_user_labels2
- WHERE
- label_id = '$label_id' AND
- article_id = '$id'");
-
- label_clear_cache($id);
- }
-
- function label_add_article($id, $label, $owner_uid) {
-
- $label_id = label_find_id($label, $owner_uid);
-
- if (!$label_id) return;
-
- $result = db_query(
- "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("INSERT INTO ttrss_user_labels2
- (label_id, article_id) VALUES ('$label_id', '$id')");
- }
-
- label_clear_cache($id);
-
- }
-
- function label_remove($id, $owner_uid) {
- if (!$owner_uid) $owner_uid = $_SESSION["uid"];
-
- db_query("BEGIN");
-
- $result = db_query("SELECT caption FROM ttrss_labels2
- WHERE id = '$id'");
-
- $caption = db_fetch_result($result, 0, "caption");
-
- $result = db_query("DELETE FROM ttrss_labels2 WHERE id = '$id'
- AND owner_uid = " . $owner_uid);
-
- if (db_affected_rows($result) != 0 && $caption) {
-
- /* Remove access key for the label */
-
- $ext_id = LABEL_BASE_INDEX - 1 - $id;
-
- db_query("DELETE FROM ttrss_access_keys WHERE
- feed_id = '$ext_id' AND owner_uid = $owner_uid");
-
- /* Remove cached data */
-
- db_query("UPDATE ttrss_user_entries SET label_cache = ''
- WHERE label_cache LIKE '%$caption%' AND owner_uid = " . $owner_uid);
-
- }
-
- db_query("COMMIT");
- }
-
- function label_create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) {
-
- if (!$owner_uid) $owner_uid = $_SESSION['uid'];
-
- db_query("BEGIN");
-
- $result = false;
-
- $result = db_query("SELECT id FROM ttrss_labels2
- WHERE caption = '$caption' AND owner_uid = $owner_uid");
-
- if (db_num_rows($result) == 0) {
- $result = db_query(
- "INSERT INTO ttrss_labels2 (caption,owner_uid,fg_color,bg_color)
- VALUES ('$caption', '$owner_uid', '$fg_color', '$bg_color')");
-
- $result = db_affected_rows($result) != 0;
- }
-
- db_query("COMMIT");
-
- return $result;
- }