From 73fe13afd47d4e8d31ffd5f09fc602415e5f1207 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 8 Nov 2010 16:34:49 +0300 Subject: [PATCH] add ttrss_users.full_name; bump schema --- modules/popup-dialog.php | 6 ++++-- modules/pref-prefs.php | 25 ++++++++++++++++++------- prefs.js | 2 +- sanity_check.php | 2 +- schema/ttrss_schema_mysql.sql | 3 ++- schema/ttrss_schema_pgsql.sql | 3 ++- schema/versions/mysql/70.sql | 6 ++++++ schema/versions/pgsql/70.sql | 6 ++++++ 8 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 schema/versions/mysql/70.sql create mode 100644 schema/versions/pgsql/70.sql diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 61efd4c9..4c8c92b5 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -654,11 +654,13 @@ print ""; print ""; - $result = db_query($link, "SELECT email FROM ttrss_users WHERE + $result = db_query($link, "SELECT email, full_name FROM ttrss_users WHERE id = " . $_SESSION["uid"]); $user_email = htmlspecialchars(db_fetch_result($result, 0, "email")); - $user_name = htmlspecialchars($_SESSION["name"]); + $user_name = htmlspecialchars(db_fetch_result($result, 0, "full_name")); + + if (!$user_name) $user_name = $_SESSION['name']; $_SESSION['email_replyto'] = $user_email; $_SESSION['email_fromname'] = $user_name; diff --git a/modules/pref-prefs.php b/modules/pref-prefs.php index dc658956..5fcb9311 100644 --- a/modules/pref-prefs.php +++ b/modules/pref-prefs.php @@ -123,12 +123,14 @@ } else if ($subop == "change-email") { $email = db_escape_string($_POST["email"]); + $full_name = db_escape_string($_POST["full_name"]); + $active_uid = $_SESSION["uid"]; - db_query($link, "UPDATE ttrss_users SET email = '$email' - WHERE id = '$active_uid'"); + db_query($link, "UPDATE ttrss_users SET email = '$email', + full_name = '$full_name' WHERE id = '$active_uid'"); - print __("E-mail has been changed."); + print __("Your personal data has been saved."); return; @@ -197,11 +199,20 @@ print ""; print ""; - $result = db_query($link, "SELECT email,access_level FROM ttrss_users + $result = db_query($link, "SELECT email,full_name, + access_level FROM ttrss_users WHERE id = ".$_SESSION["uid"]); - $email = db_fetch_result($result, 0, "email"); - + $email = htmlspecialchars(db_fetch_result($result, 0, "email")); + $full_name = htmlspecialchars(db_fetch_result($result, 0, "full_name")); + + print ""; + print ""; + print ""; print "

".__("Personal data")."

".__('Full name')."
".__('E-mail').""; print "

"; + __("Save data").""; print "

"; diff --git a/prefs.js b/prefs.js index 33ed8fd7..c590c61f 100644 --- a/prefs.js +++ b/prefs.js @@ -1548,7 +1548,7 @@ function changeUserEmail() { var query = Form.serialize("change_email_form"); - notify_progress("Trying to change e-mail..."); + notify_progress("Saving..."); new Ajax.Request("backend.php", { parameters: query, diff --git a/sanity_check.php b/sanity_check.php index 437ac0a0..0f539bde 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 19); - define('SCHEMA_VERSION', 69); + define('SCHEMA_VERSION', 70); if (!file_exists("config.php")) { print "Fatal Error: You forgot to copy diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 33c1f3d9..03ea5e61 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -48,6 +48,7 @@ create table ttrss_users (id integer primary key not null auto_increment, access_level integer not null default 0, theme_id integer default null, email varchar(250) not null default '', + full_name varchar(250) not null default '', email_digest bool not null default false, last_digest_sent datetime default null, created datetime default null, @@ -242,7 +243,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB DEFAULT CHARSET=UTF8; -insert into ttrss_version values (69); +insert into ttrss_version values (70); create table ttrss_enclosures (id integer primary key auto_increment, content_url text not null, diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 69753aa3..2d1f33c6 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -45,6 +45,7 @@ create table ttrss_users (id serial not null primary key, last_login timestamp default null, access_level integer not null default 0, email varchar(250) not null default '', + full_name varchar(250) not null default '', email_digest boolean not null default false, last_digest_sent timestamp default null, created timestamp default null, @@ -214,7 +215,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (69); +insert into ttrss_version values (70); create table ttrss_enclosures (id serial not null primary key, content_url text not null, diff --git a/schema/versions/mysql/70.sql b/schema/versions/mysql/70.sql new file mode 100644 index 00000000..0c64336d --- /dev/null +++ b/schema/versions/mysql/70.sql @@ -0,0 +1,6 @@ +alter table ttrss_users add column full_name varchar(250); +update ttrss_users set full_name = ''; +alter table ttrss_users change full_name full_name varchar(250) not null; +alter table ttrss_users alter column full_name set default ''; + +update ttrss_version set schema_version = 70; diff --git a/schema/versions/pgsql/70.sql b/schema/versions/pgsql/70.sql new file mode 100644 index 00000000..b970a861 --- /dev/null +++ b/schema/versions/pgsql/70.sql @@ -0,0 +1,6 @@ +alter table ttrss_users add column full_name varchar(250); +update ttrss_users set full_name = ''; +alter table ttrss_users alter column full_name set not null; +alter table ttrss_users alter column full_name set default ''; + +update ttrss_version set schema_version = 70;