]> git.wh0rd.org Git - tt-rss.git/commitdiff
updating issue fix for schema 63 (2)
authorAndrew Dolgov <fox@bah.org.ru>
Wed, 13 Jan 2010 18:30:17 +0000 (21:30 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Wed, 13 Jan 2010 18:30:17 +0000 (21:30 +0300)
db-prefs.php
functions.php

index 15f03c094bfc653500530933618c8e908302303f..5c54427b7ed893d532fdfa56267056d6d8477d23 100644 (file)
                }
 
                if ($profile) {
-                       $profile_qpart = "profile = '$profile'";
+                       $profile_qpart = "profile = '$profile' AND";
                } else {
-                       $profile_qpart = "profile IS NULL";
+                       $profile_qpart = "profile IS NULL AND";
                }
 
+               if (get_schema_version($link) < 63) $profile_qpart = "";
 
                if ($prefs_cache && !defined('DISABLE_SESSIONS') && !SINGLE_USER_MODE) {        
                        if ($_SESSION["prefs_cache"] && $_SESSION["prefs_cache"][$pref_name]) {
@@ -39,7 +40,7 @@
                        FROM 
                                ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
                        WHERE 
-                               $profile_qpart AND
+                               $profile_qpart
                                ttrss_user_prefs.pref_name = '$pref_name' AND 
                                ttrss_prefs_types.id = type_id AND
                                owner_uid = '$user_id' AND
                }
 
                if ($profile) {
-                       $profile_qpart = "profile = '$profile'";
+                       $profile_qpart = "AND profile = '$profile'";
                } else {
-                       $profile_qpart = "profile IS NULL";
+                       $profile_qpart = "AND profile IS NULL AND";
                }
 
+               if (get_schema_version($link) < 63) $profile_qpart = "";
+
                $result = db_query($link, "SELECT type_name 
                        FROM ttrss_prefs,ttrss_prefs_types 
                        WHERE pref_name = '$key' AND type_id = ttrss_prefs_types.id");
 
                        db_query($link, "UPDATE ttrss_user_prefs SET 
                                value = '$value' WHERE pref_name = '$key' 
-                                       AND $profile_qpart
+                                       $profile_qpart
                                        AND owner_uid = " . $_SESSION["uid"]);
 
                        $_SESSION["prefs_cache"] = array();
index f6ce227f036a3a294d792e82b6fdc5f1d2b5c70c..507595e77c629bb358efb55a1489bd64c02902ff 100644 (file)
 
                if (!$profile) {
                        $profile = "NULL";
-                       $profile_qpart = "profile IS NULL";
+                       $profile_qpart = "AND profile IS NULL";
                } else {
-                       $profile_qpart = "profile = '$profile'";
+                       $profile_qpart = "AND profile = '$profile'";
                }
 
+               if (get_schema_version($link) < 63) $profile_qpart = "";
+
                db_query($link, "BEGIN");
 
                $result = db_query($link, "SELECT pref_name,def_value FROM ttrss_prefs");
                
                $u_result = db_query($link, "SELECT pref_name 
-                       FROM ttrss_user_prefs WHERE owner_uid = '$uid' AND $profile_qpart");
+                       FROM ttrss_user_prefs WHERE owner_uid = '$uid' $profile_qpart");
 
                $active_prefs = array();
 
                        if (array_search($line["pref_name"], $active_prefs) === FALSE) {
 //                             print "adding " . $line["pref_name"] . "<br>";
 
-                               db_query($link, "INSERT INTO ttrss_user_prefs
-                                       (owner_uid,pref_name,value, profile) VALUES 
-                                       ('$uid', '".$line["pref_name"]."','".$line["def_value"]."', $profile)");
+                               if (get_schema_version($link) < 63) {
+                                       db_query($link, "INSERT INTO ttrss_user_prefs
+                                               (owner_uid,pref_name,value) VALUES 
+                                               ('$uid', '".$line["pref_name"]."','".$line["def_value"]."')");
+
+                               } else {
+                                       db_query($link, "INSERT INTO ttrss_user_prefs
+                                               (owner_uid,pref_name,value, profile) VALUES 
+                                               ('$uid', '".$line["pref_name"]."','".$line["def_value"]."', $profile)");
+                               }
 
                        }
                }