]> git.wh0rd.org Git - tt-rss.git/commitdiff
main classes: remove sql_bool_to_bool() kludge
authorAndrew Dolgov <noreply@fakecake.org>
Sun, 3 Dec 2017 06:35:59 +0000 (09:35 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Sun, 3 Dec 2017 06:35:59 +0000 (09:35 +0300)
classes/article.php
classes/feeds.php
classes/handler/public.php
classes/opml.php
classes/pref/feeds.php
classes/pref/prefs.php
classes/rssutils.php

index 869e746cf195d6df22f460181bfd98ce672e7f21..0352e1b9eeede22b9e515aacf3d40ad6bf016e70 100644 (file)
@@ -8,6 +8,8 @@ class Article extends Handler_Protected {
        }
 
        function redirect() {
+               $id = $_REQUEST['id'];
+
                $sth = $this->pdo->prepare("SELECT link FROM ttrss_entries, ttrss_user_entries
                                                WHERE id = ? AND id = ref_id AND owner_uid = ?
                                                LIMIT 1");
@@ -601,7 +603,7 @@ class Article extends Handler_Protected {
                        unset($line["tag_cache"]);
 
                        $line["content"] = sanitize($line["content"],
-                               sql_bool_to_bool($line['hide_images']),
+                               $line['hide_images'],
                                $owner_uid, $line["site_url"], false, $line["id"]);
 
                        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) {
@@ -754,9 +756,9 @@ class Article extends Handler_Protected {
 
                        if (!$zoom_mode) {
                                $rv['content'] .= Article::format_article_enclosures($id,
-                                       sql_bool_to_bool($line["always_display_enclosures"]),
+                                       $line["always_display_enclosures"],
                                        $line["content"],
-                                       sql_bool_to_bool($line["hide_images"]));
+                                       $line["hide_images"]);
                        }
 
                        $rv['content'] .= "</div>";
index f2244ae89a0404f5dedc6fd8a7c4ef3533ce418e..ffb2fc5c8738a883fa63648a0809a3f6901f0053 100755 (executable)
@@ -199,7 +199,7 @@ class Feeds extends Handler_Protected {
 
                                if ($row = $sth->fetch()) {
                                        $last_updated = strtotime($row["last_updated"]);
-                                       $cache_images = sql_bool_to_bool($row["cache_images"]);
+                                       $cache_images = $row["cache_images"];
 
                                        if (!$cache_images && time() - $last_updated > 120) {
                                                RSSUtils::update_rss_feed($feed, true);
@@ -360,12 +360,12 @@ class Feeds extends Handler_Protected {
 
             $class = "";
 
-            if (sql_bool_to_bool($line["unread"])) {
+            if ($line["unread"]) {
                 $class .= " Unread";
                 ++$num_unread;
             }
 
-            if (sql_bool_to_bool($line["marked"])) {
+            if ($line["marked"]) {
                 $marked_pic = "<img
                     src=\"images/mark_set.png\"
                     class=\"markedPic\" alt=\"Unstar article\"
@@ -378,7 +378,7 @@ class Feeds extends Handler_Protected {
                     onclick='toggleMark($id)'>";
             }
 
-            if (sql_bool_to_bool($line["published"])) {
+            if ($line["published"]) {
                 $published_pic = "<img src=\"images/pub_set.png\"
                     class=\"pubPic\"
                         alt=\"Unpublish article\" onclick='togglePub($id)'>";
@@ -528,7 +528,7 @@ class Feeds extends Handler_Protected {
                     $tags = false;
 
                 $line["content"] = sanitize($line["content"],
-                        sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
+                        $line['hide_images'], false, $entry_site_url, $highlight_words, $line["id"]);
 
                 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
                     $line = $p->hook_render_article_cdm($line);
@@ -690,7 +690,7 @@ class Feeds extends Handler_Protected {
 
                 $tmp_content .= "<div class=\"cdmIntermediate\">";
 
-                $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
+                $always_display_enclosures = $line["always_display_enclosures"];
                 $tmp_content .= Article::format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
 
                 $tmp_content .= "</div>"; // cdmIntermediate
index f36ee8b1aebdbacaa8e6004c7d415e205e8822a3..8b513df6770e73a9635def7e47c4c634205075c9 100644 (file)
@@ -15,14 +15,11 @@ class Handler_Public extends Handler {
                if (!$limit) $limit = 60;
 
                $date_sort_field = "date_entered DESC, updated DESC";
-               $date_check_field = "date_entered";
 
                if ($feed == -2 && !$is_cat) {
                        $date_sort_field = "last_published DESC";
-                       $date_check_field = "last_published";
                } else if ($feed == -1 && !$is_cat) {
                        $date_sort_field = "last_marked DESC";
-                       $date_check_field = "last_marked";
                }
 
                switch ($order) {
@@ -295,7 +292,7 @@ class Handler_Public extends Handler {
        function rss() {
                $feed = $_REQUEST["id"];
                $key = $_REQUEST["key"];
-               $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
+               $is_cat = $_REQUEST["is_cat"];
                $limit = (int)$_REQUEST["limit"];
                $offset = (int)$_REQUEST["offset"];
 
@@ -305,7 +302,7 @@ class Handler_Public extends Handler {
                $start_ts = $_REQUEST["ts"];
 
                $format = $_REQUEST['format'];
-               $orig_guid = sql_bool_to_bool($_REQUEST["orig_guid"]);
+               $orig_guid = $_REQUEST["orig_guid"];
 
                if (!$format) $format = 'atom';
 
index 5f70558b6c15189817cb1b7a6673d151a855145e..98ea21a5ce97eff9932e151294e8bc08c98b0fb4 100644 (file)
@@ -173,10 +173,6 @@ class Opml extends Handler_Protected {
                        $sth->execute([$owner_uid]);
 
                        while ($line = $sth->fetch()) {
-                               foreach (array('enabled', 'match_any_rule', 'inverse') as $b) {
-                                       $line[$b] = sql_bool_to_bool($line[$b]);
-                               }
-
                                $line["rules"] = array();
                                $line["actions"] = array();
 
@@ -188,7 +184,7 @@ class Opml extends Handler_Protected {
                                        unset($tmp_line["id"]);
                                        unset($tmp_line["filter_id"]);
 
-                                       $cat_filter = sql_bool_to_bool($tmp_line["cat_filter"]);
+                                       $cat_filter = $tmp_line["cat_filter"];
 
                                        if (!$tmp_line["match_on"]) {
                         if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
@@ -222,9 +218,6 @@ class Opml extends Handler_Protected {
                                            unset($tmp_line["match_on"]);
                     }
 
-                                       $tmp_line["cat_filter"] = sql_bool_to_bool($tmp_line["cat_filter"]);
-                                       $tmp_line["inverse"] = sql_bool_to_bool($tmp_line["inverse"]);
-
                                        unset($tmp_line["feed_id"]);
                                        unset($tmp_line["cat_id"]);
 
index fcd2aedad5219e771f405c3c80d7395204478c5a..9f7ada24492e1c4cd64031f99cdf26560170face 100755 (executable)
@@ -510,7 +510,7 @@ class Pref_Feeds extends Handler_Protected {
                        print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
                        <div dojoType="dijit.layout.ContentPane" title="'.__('General').'">';
 
-                       $auth_pass_encrypted = sql_bool_to_bool($row["auth_pass_encrypted"]);
+                       $auth_pass_encrypted = $row["auth_pass_encrypted"];
 
                        $title = htmlspecialchars($row["title"]);
 
@@ -644,7 +644,7 @@ class Pref_Feeds extends Handler_Protected {
                        //print "<div class=\"dlgSec\">".__("Options")."</div>";
                        print "<div class=\"dlgSecSimple\">";
 
-                       $private = sql_bool_to_bool($row["private"]);
+                       $private = $row["private"];
 
                        if ($private) {
                                $checked = "checked=\"1\"";
@@ -655,7 +655,7 @@ class Pref_Feeds extends Handler_Protected {
                        print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\"
                        $checked>&nbsp;<label for=\"private\">".__('Hide from Popular feeds')."</label>";
 
-                       $include_in_digest = sql_bool_to_bool($row["include_in_digest"]);
+                       $include_in_digest = $row["include_in_digest"];
 
                        if ($include_in_digest) {
                                $checked = "checked=\"1\"";
@@ -668,7 +668,7 @@ class Pref_Feeds extends Handler_Protected {
                        $checked>&nbsp;<label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
 
 
-                       $always_display_enclosures = sql_bool_to_bool($row["always_display_enclosures"]);
+                       $always_display_enclosures = $row["always_display_enclosures"];
 
                        if ($always_display_enclosures) {
                                $checked = "checked";
@@ -680,7 +680,7 @@ class Pref_Feeds extends Handler_Protected {
                        name=\"always_display_enclosures\"
                        $checked>&nbsp;<label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
 
-                       $hide_images = sql_bool_to_bool($row["hide_images"]);
+                       $hide_images = $row["hide_images"];
 
                        if ($hide_images) {
                                $checked = "checked=\"1\"";
@@ -693,7 +693,7 @@ class Pref_Feeds extends Handler_Protected {
                        $checked>&nbsp;<label for=\"hide_images\">".
                                __('Do not embed images')."</label>";
 
-                       $cache_images = sql_bool_to_bool($row["cache_images"]);
+                       $cache_images = $row["cache_images"];
 
                        if ($cache_images) {
                                $checked = "checked=\"1\"";
@@ -706,7 +706,7 @@ class Pref_Feeds extends Handler_Protected {
                        $checked>&nbsp;<label for=\"cache_images\">".
                                __('Cache media')."</label>";
 
-                       $mark_unread_on_update = sql_bool_to_bool($row["mark_unread_on_update"]);
+                       $mark_unread_on_update = $row["mark_unread_on_update"];
 
                        if ($mark_unread_on_update) {
                                $checked = "checked";
index ab39b1e286d8c49a7146f1e3c70c11de21596372..ff778cbceac6fcdf7e595614e3d25a31c7c61912 100644 (file)
@@ -207,7 +207,7 @@ class Pref_Prefs extends Handler_Protected {
 
                $email = htmlspecialchars($row["email"]);
                $full_name = htmlspecialchars($row["full_name"]);
-               $otp_enabled = sql_bool_to_bool($row["otp_enabled"]);
+               $otp_enabled = $row["otp_enabled"];
 
                print "<tr><td width=\"40%\">".__('Full name')."</td>";
                print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\"
@@ -864,7 +864,7 @@ class Pref_Prefs extends Handler_Protected {
                        $base32 = new Base32();
 
                        $login = $row["login"];
-                       $otp_enabled = sql_bool_to_bool($row["otp_enabled"]);
+                       $otp_enabled = $row["otp_enabled"];
 
                        if (!$otp_enabled) {
                                $secret = $base32->encode(sha1($row["salt"]));
index a511a74c8652a509d321dde442800c566a11b3a7..696b8604cce4b88b4811af07bab363af99b62acb 100644 (file)
@@ -221,7 +221,7 @@ class RSSUtils {
 
                        $owner_uid = $row["owner_uid"];
 
-                       $auth_pass_encrypted = sql_bool_to_bool($row["auth_pass_encrypted"]);
+                       $auth_pass_encrypted = $row["auth_pass_encrypted"];
 
                        $auth_login = $row["auth_login"];
                        $auth_pass = $row["auth_pass"];
@@ -341,8 +341,8 @@ class RSSUtils {
                if ($row = $sth->fetch()) {
 
                        $owner_uid = $row["owner_uid"];
-                       $mark_unread_on_update = sql_bool_to_bool($row["mark_unread_on_update"]);
-                       $auth_pass_encrypted = sql_bool_to_bool($row["auth_pass_encrypted"]);
+                       $mark_unread_on_update = $row["mark_unread_on_update"];
+                       $auth_pass_encrypted = $row["auth_pass_encrypted"];
 
                        $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_update_started = NOW()
                                WHERE id = ?");
@@ -358,7 +358,7 @@ class RSSUtils {
 
                        $stored_last_modified = $row["last_modified"];
                        $last_unconditional = $row["last_unconditional"];
-                       $cache_images = sql_bool_to_bool($row["cache_images"]);
+                       $cache_images = $row["cache_images"];
                        $fetch_url = $row["feed_url"];
                        $feed_language = mb_strtolower($row["feed_language"]);
                        if (!$feed_language) $feed_language = 'english';
@@ -515,7 +515,7 @@ class RSSUtils {
                        $sth->execute([$feed]);
 
                        if ($row = $sth->fetch()) {
-                               $favicon_needs_check = sql_bool_to_bool($row["favicon_needs_check"]);
+                               $favicon_needs_check = $row["favicon_needs_check"];
                                $favicon_avg_color = $row["favicon_avg_color"];
                                $owner_uid = $row["owner_uid"];
                        } else {
@@ -883,7 +883,7 @@ class RSSUtils {
                                                        $entry_current_hash,
                                                        $date_feed_processed,
                                                        $entry_comments,
-                                                       $num_comments,
+                                                       (int)$num_comments,
                                                        $entry_plugin_data,
                                                        $entry_language,
                                                        $entry_author]);
@@ -995,7 +995,7 @@ class RSSUtils {
                                                WHERE id = ?");
 
                                        $sth->execute([$entry_title, $entry_content, $entry_current_hash, $entry_timestamp_fmt,
-                                               $num_comments, $entry_plugin_data, $entry_author, $entry_language, $ref_id]);
+                                               (int)$num_comments, $entry_plugin_data, $entry_author, $entry_language, $ref_id]);
 
                                        // update aux data
                                        $sth = $pdo->prepare("UPDATE ttrss_user_entries