diff options
author | Andrew Dolgov <[email protected]> | 2005-11-18 06:17:17 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2005-11-18 06:17:17 +0100 |
commit | ff485f1d509abd45638dac0e8d644f3496a5b072 (patch) | |
tree | 7482625c953633f0975e1c69476d8abd67d8225f /functions.php | |
parent | 46a1969d75faabb9b941287b3de3e6a6de782feb (diff) |
per-user preferences
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/functions.php b/functions.php index 8b6bc6620..d07ce024f 100644 --- a/functions.php +++ b/functions.php @@ -484,4 +484,36 @@ } } + function initialize_user_prefs($link, $uid) { + + $uid = db_escape_string($uid); + + 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'"); + + $active_prefs = array(); + + while ($line = db_fetch_assoc($u_result)) { + array_push($active_prefs, $line["pref_name"]); + } + + while ($line = db_fetch_assoc($result)) { + 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) VALUES + ('$uid', '".$line["pref_name"]."','".$line["def_value"]."')"); + + } + } + + db_query($link, "COMMIT"); + + } + ?> |