mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 17:35:56 +00:00
classes: use OO DB interface
This commit is contained in:
@@ -8,12 +8,12 @@ class Pref_Labels extends Handler_Protected {
|
||||
}
|
||||
|
||||
function edit() {
|
||||
$label_id = db_escape_string($_REQUEST['id']);
|
||||
$label_id = $this->dbh->escape_string($_REQUEST['id']);
|
||||
|
||||
$result = db_query("SELECT * FROM ttrss_labels2 WHERE
|
||||
$result = $this->dbh->query("SELECT * FROM ttrss_labels2 WHERE
|
||||
id = '$label_id' AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$line = db_fetch_assoc($result);
|
||||
$line = $this->dbh->fetch_assoc($result);
|
||||
|
||||
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$label_id\">";
|
||||
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-labels\">";
|
||||
@@ -90,12 +90,12 @@ class Pref_Labels extends Handler_Protected {
|
||||
$root['name'] = __('Labels');
|
||||
$root['items'] = array();
|
||||
|
||||
$result = db_query("SELECT *
|
||||
$result = $this->dbh->query("SELECT *
|
||||
FROM ttrss_labels2
|
||||
WHERE owner_uid = ".$_SESSION["uid"]."
|
||||
ORDER BY caption");
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
while ($line = $this->dbh->fetch_assoc($result)) {
|
||||
$label = array();
|
||||
$label['id'] = 'LABEL:' . $line['id'];
|
||||
$label['bare_id'] = $line['id'];
|
||||
@@ -118,29 +118,29 @@ class Pref_Labels extends Handler_Protected {
|
||||
}
|
||||
|
||||
function colorset() {
|
||||
$kind = db_escape_string($_REQUEST["kind"]);
|
||||
$ids = explode(',', db_escape_string($_REQUEST["ids"]));
|
||||
$color = db_escape_string($_REQUEST["color"]);
|
||||
$fg = db_escape_string($_REQUEST["fg"]);
|
||||
$bg = db_escape_string($_REQUEST["bg"]);
|
||||
$kind = $this->dbh->escape_string($_REQUEST["kind"]);
|
||||
$ids = explode(',', $this->dbh->escape_string($_REQUEST["ids"]));
|
||||
$color = $this->dbh->escape_string($_REQUEST["color"]);
|
||||
$fg = $this->dbh->escape_string($_REQUEST["fg"]);
|
||||
$bg = $this->dbh->escape_string($_REQUEST["bg"]);
|
||||
|
||||
foreach ($ids as $id) {
|
||||
|
||||
if ($kind == "fg" || $kind == "bg") {
|
||||
db_query("UPDATE ttrss_labels2 SET
|
||||
$this->dbh->query("UPDATE ttrss_labels2 SET
|
||||
${kind}_color = '$color' WHERE id = '$id'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
} else {
|
||||
db_query("UPDATE ttrss_labels2 SET
|
||||
$this->dbh->query("UPDATE ttrss_labels2 SET
|
||||
fg_color = '$fg', bg_color = '$bg' WHERE id = '$id'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
}
|
||||
|
||||
$caption = db_escape_string(label_find_caption($id, $_SESSION["uid"]));
|
||||
$caption = $this->dbh->escape_string(label_find_caption($id, $_SESSION["uid"]));
|
||||
|
||||
/* Remove cached data */
|
||||
|
||||
db_query("UPDATE ttrss_user_entries SET label_cache = ''
|
||||
$this->dbh->query("UPDATE ttrss_user_entries SET label_cache = ''
|
||||
WHERE label_cache LIKE '%$caption%' AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
}
|
||||
@@ -149,18 +149,18 @@ class Pref_Labels extends Handler_Protected {
|
||||
}
|
||||
|
||||
function colorreset() {
|
||||
$ids = explode(',', db_escape_string($_REQUEST["ids"]));
|
||||
$ids = explode(',', $this->dbh->escape_string($_REQUEST["ids"]));
|
||||
|
||||
foreach ($ids as $id) {
|
||||
db_query("UPDATE ttrss_labels2 SET
|
||||
$this->dbh->query("UPDATE ttrss_labels2 SET
|
||||
fg_color = '', bg_color = '' WHERE id = '$id'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$caption = db_escape_string(label_find_caption($id, $_SESSION["uid"]));
|
||||
$caption = $this->dbh->escape_string(label_find_caption($id, $_SESSION["uid"]));
|
||||
|
||||
/* Remove cached data */
|
||||
|
||||
db_query("UPDATE ttrss_user_entries SET label_cache = ''
|
||||
$this->dbh->query("UPDATE ttrss_user_entries SET label_cache = ''
|
||||
WHERE label_cache LIKE '%$caption%' AND owner_uid = " . $_SESSION["uid"]);
|
||||
}
|
||||
|
||||
@@ -168,31 +168,31 @@ class Pref_Labels extends Handler_Protected {
|
||||
|
||||
function save() {
|
||||
|
||||
$id = db_escape_string($_REQUEST["id"]);
|
||||
$caption = db_escape_string(trim($_REQUEST["caption"]));
|
||||
$id = $this->dbh->escape_string($_REQUEST["id"]);
|
||||
$caption = $this->dbh->escape_string(trim($_REQUEST["caption"]));
|
||||
|
||||
db_query("BEGIN");
|
||||
$this->dbh->query("BEGIN");
|
||||
|
||||
$result = db_query("SELECT caption FROM ttrss_labels2
|
||||
$result = $this->dbh->query("SELECT caption FROM ttrss_labels2
|
||||
WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
|
||||
|
||||
if (db_num_rows($result) != 0) {
|
||||
$old_caption = db_fetch_result($result, 0, "caption");
|
||||
if ($this->dbh->num_rows($result) != 0) {
|
||||
$old_caption = $this->dbh->fetch_result($result, 0, "caption");
|
||||
|
||||
$result = db_query("SELECT id FROM ttrss_labels2
|
||||
$result = $this->dbh->query("SELECT id FROM ttrss_labels2
|
||||
WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
|
||||
|
||||
if (db_num_rows($result) == 0) {
|
||||
if ($this->dbh->num_rows($result) == 0) {
|
||||
if ($caption) {
|
||||
$result = db_query("UPDATE ttrss_labels2 SET
|
||||
$result = $this->dbh->query("UPDATE ttrss_labels2 SET
|
||||
caption = '$caption' WHERE id = '$id' AND
|
||||
owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
/* Update filters that reference label being renamed */
|
||||
|
||||
$old_caption = db_escape_string($old_caption);
|
||||
$old_caption = $this->dbh->escape_string($old_caption);
|
||||
|
||||
db_query("UPDATE ttrss_filters2_actions SET
|
||||
$this->dbh->query("UPDATE ttrss_filters2_actions SET
|
||||
action_param = '$caption' WHERE action_param = '$old_caption'
|
||||
AND action_id = 7
|
||||
AND filter_id IN (SELECT id FROM ttrss_filters2 WHERE owner_uid = ".$_SESSION["uid"].")");
|
||||
@@ -206,14 +206,14 @@ class Pref_Labels extends Handler_Protected {
|
||||
}
|
||||
}
|
||||
|
||||
db_query("COMMIT");
|
||||
$this->dbh->query("COMMIT");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function remove() {
|
||||
|
||||
$ids = explode(",", db_escape_string($_REQUEST["ids"]));
|
||||
$ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
|
||||
|
||||
foreach ($ids as $id) {
|
||||
label_remove($id, $_SESSION["uid"]);
|
||||
@@ -222,8 +222,8 @@ class Pref_Labels extends Handler_Protected {
|
||||
}
|
||||
|
||||
function add() {
|
||||
$caption = db_escape_string($_REQUEST["caption"]);
|
||||
$output = db_escape_string($_REQUEST["output"]);
|
||||
$caption = $this->dbh->escape_string($_REQUEST["caption"]);
|
||||
$output = $this->dbh->escape_string($_REQUEST["output"]);
|
||||
|
||||
if ($caption) {
|
||||
|
||||
@@ -250,13 +250,13 @@ class Pref_Labels extends Handler_Protected {
|
||||
|
||||
function index() {
|
||||
|
||||
$sort = db_escape_string($_REQUEST["sort"]);
|
||||
$sort = $this->dbh->escape_string($_REQUEST["sort"]);
|
||||
|
||||
if (!$sort || $sort == "undefined") {
|
||||
$sort = "caption";
|
||||
}
|
||||
|
||||
$label_search = db_escape_string($_REQUEST["search"]);
|
||||
$label_search = $this->dbh->escape_string($_REQUEST["search"]);
|
||||
|
||||
if (array_key_exists("search", $_REQUEST)) {
|
||||
$_SESSION["prefs_label_search"] = $label_search;
|
||||
|
||||
Reference in New Issue
Block a user