diff --git a/dump/forum.sql b/dump/forum.sql index 35932dd2..41dda256 100644 --- a/dump/forum.sql +++ b/dump/forum.sql @@ -1052,6 +1052,7 @@ CREATE TABLE `qa_users` ( `sessioncode` char(8) CHARACTER SET ascii NOT NULL DEFAULT '', `sessionsource` varchar(16) CHARACTER SET ascii DEFAULT '', `flags` smallint(5) unsigned NOT NULL DEFAULT '0', + `pwemail` smallint(5) unsigned NOT NULL DEFAULT '1', `wallposts` mediumint(9) NOT NULL DEFAULT '0', `oemail` varchar(80) DEFAULT NULL, PRIMARY KEY (`userid`), @@ -1068,7 +1069,7 @@ CREATE TABLE `qa_users` ( LOCK TABLES `qa_users` WRITE; /*!40000 ALTER TABLE `qa_users` DISABLE KEYS */; -INSERT INTO `qa_users` VALUES (1,'2016-05-16 19:07:12',3232264193,'superadmin@example.com','superadmin',NULL,NULL,NULL,'ej9ygqwm1r2vmetq','\"\\c_xǂ`\\{EN\rE',120,'2016-05-16 20:25:59',3232264193,'2016-05-16 20:17:59',3232264193,'','xgb3w1k0',NULL,0,0,NULL),(2,'2016-05-16 20:03:13',3232264193,'admin@example.com','admin',NULL,NULL,NULL,'7tys2ocm8ed0k5kg','}ׯ\Z߿ƟM\Z8',100,'2016-05-16 20:04:55',3232264193,'2016-05-16 20:05:23',3232264193,'','xzolja3l',NULL,0,0,NULL),(3,'2016-05-16 20:06:30',3232264193,'moderator@example.com','moderator',NULL,NULL,NULL,'pdboxxge4xzn3p82','$ܮ{^',80,'2016-05-16 20:06:30',3232264193,'2016-05-16 20:06:47',3232264193,'','mynnvaft',NULL,0,0,NULL),(4,'2016-05-16 20:07:05',3232264193,'redaktor@example.com','redaktor',NULL,NULL,NULL,'yzxqtbvtpynomair',' 'CHAR(8) CHARACTER SET ascii NOT NULL DEFAULT \'\'', // for comparing against session cookie in browser 'sessionsource' => 'VARCHAR (16) CHARACTER SET ascii DEFAULT \'\'', // e.g. facebook, openid, etc... 'flags' => 'SMALLINT UNSIGNED NOT NULL DEFAULT 0', // see constants at top of qa-app-users.php + 'pwemail' => 'SMALLINT UNSIGNED NOT NULL DEFAULT 1', 'wallposts' => 'MEDIUMINT NOT NULL DEFAULT 0', // cached count of wall posts 'PRIMARY KEY (userid)', 'KEY email (email)', @@ -1498,4 +1499,4 @@ function qa_db_upgrade_progress($text) /* Omit PHP closing tag to help avoid accidental output -*/ \ No newline at end of file +*/ diff --git a/forum/qa-include/db/selects.php b/forum/qa-include/db/selects.php index 09b7ee01..8a2e5f8b 100644 --- a/forum/qa-include/db/selects.php +++ b/forum/qa-include/db/selects.php @@ -1182,7 +1182,7 @@ function qa_db_user_account_selectspec($useridhandle, $isuserid) return array( 'columns' => array( '^users.userid', 'passsalt', 'passcheck' => 'HEX(passcheck)', 'email', 'level', 'emailcode', 'handle', - 'created' => 'UNIX_TIMESTAMP(created)', 'sessioncode', 'sessionsource', 'flags', 'loggedin' => 'UNIX_TIMESTAMP(loggedin)', + 'created' => 'UNIX_TIMESTAMP(created)', 'sessioncode', 'sessionsource', 'flags', 'pwemail', 'loggedin' => 'UNIX_TIMESTAMP(loggedin)', 'loginip' => 'INET_NTOA(loginip)', 'written' => 'UNIX_TIMESTAMP(written)', 'writeip' => 'INET_NTOA(writeip)', 'avatarblobid' => 'BINARY avatarblobid', // cast to BINARY due to MySQL bug which renders it signed in a union 'avatarwidth', 'avatarheight', 'points', 'wallposts', @@ -1695,4 +1695,4 @@ function qa_db_user_levels_selectspec($identifier, $isuserid=QA_FINAL_EXTERNAL_U /* Omit PHP closing tag to help avoid accidental output -*/ \ No newline at end of file +*/ diff --git a/forum/qa-include/lang/qa-lang-users.php b/forum/qa-include/lang/qa-lang-users.php index d6f9965e..f67f46f6 100644 --- a/forum/qa-include/lang/qa-lang-users.php +++ b/forum/qa-include/lang/qa-lang-users.php @@ -99,7 +99,9 @@ 'password_to_set' => 'Please set on your account page', 'password_wrong' => 'Password not correct', 'private_messages' => 'Private messages:', + 'private_messages_email' => 'Private message notifications:', 'private_messages_explanation' => 'Allow users to email you (without seeing your address)', + 'private_messages_email_explanation' => 'Notify me by e-mail when we receive a private message', 'profile_saved' => 'Profile saved', 'register_button' => 'Register', 'register_limit' => 'Too many registrations - please try again in an hour', @@ -139,4 +141,4 @@ /* Omit PHP closing tag to help avoid accidental output -*/ \ No newline at end of file +*/ diff --git a/forum/qa-include/pages/account.php b/forum/qa-include/pages/account.php index cd66cef9..25275023 100644 --- a/forum/qa-include/pages/account.php +++ b/forum/qa-include/pages/account.php @@ -71,6 +71,7 @@ $inhandle = $changehandle ? qa_post_text('handle') : $useraccount['handle']; $inemail = qa_post_text('email'); $inmessages = qa_post_text('messages'); + $inmessagesemail = (int)qa_post_text('messages_email'); $inwallposts = qa_post_text('wall'); $inmailings = qa_post_text('mailings'); $inavatar = qa_post_text('avatar'); @@ -97,6 +98,10 @@ qa_send_new_confirm($userid); } + if ($inmessagesemail !== $useraccount['pwemail'] && ($inmessagesemail === 0 || $inmessagesemail === 1)) { + qa_db_query_sub('UPDATE ^users SET pwemail=# WHERE userid=#', $inmessagesemail, $userid); + } + if (qa_opt('allow_private_messages')) qa_db_user_set_flag($userid, QA_USER_FLAGS_NO_MESSAGES, !$inmessages); @@ -253,6 +258,14 @@ 'note' => qa_lang_html('users/private_messages_explanation'), ), + 'messages_email' => array( + 'label' => qa_lang_html('users/private_messages_email'), + 'tags' => 'name="messages_email"', + 'type' => 'checkbox', + 'value' => $useraccount['pwemail'], + 'note' => qa_lang_html('users/private_messages_email_explanation'), + ), + 'wall' => array( 'label' => qa_lang_html('users/wall_posts'), 'tags' => 'name="wall"', diff --git a/forum/qa-include/pages/message.php b/forum/qa-include/pages/message.php index 32b93d89..c70d49c4 100644 --- a/forum/qa-include/pages/message.php +++ b/forum/qa-include/pages/message.php @@ -122,23 +122,30 @@ $messageid = null; $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES); - - $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array( - '^f_handle' => $fromhandle, - '^url' => qa_path_absolute($canreply ? ('message/'.$fromhandle) : ('user/'.$fromhandle)), - )); - - $subs = array( - '^message' => $inmessage, - '^f_handle' => $fromhandle, - '^f_url' => qa_path_absolute('user/'.$fromhandle), - '^more' => $more, - '^a_url' => qa_path_absolute('account'), - ); - - if (qa_send_notification($toaccount['userid'], $toaccount['email'], $toaccount['handle'], - qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs)) - $messagesent = true; + if ($toaccount['pwemail'] == 1) { + $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array( + '^f_handle' => $fromhandle, + '^url' => qa_path_absolute($canreply ? ('message/'.$fromhandle) : ('user/'.$fromhandle)), + )); + + $subs = array( + '^message' => $inmessage, + '^f_handle' => $fromhandle, + '^f_url' => qa_path_absolute('user/'.$fromhandle), + '^more' => $more, + '^a_url' => qa_path_absolute('account'), + ); + + qa_send_notification( + $toaccount['userid'], + $toaccount['email'], + $toaccount['handle'], + qa_lang('emails/private_message_subject'), + qa_lang('emails/private_message_body'), + $subs + ); + } + $messagesent = true; qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array( 'userid' => $toaccount['userid'], @@ -240,4 +247,4 @@ /* Omit PHP closing tag to help avoid accidental output -*/ \ No newline at end of file +*/ diff --git a/forum/qa-lang/pl/qa-lang-users.php b/forum/qa-lang/pl/qa-lang-users.php index d9ab1bf2..b8f87a96 100644 --- a/forum/qa-lang/pl/qa-lang-users.php +++ b/forum/qa-lang/pl/qa-lang-users.php @@ -99,7 +99,9 @@ 'password_to_set' => 'Ustaw na stronie swojego profilu', 'password_wrong' => 'Nieprawidłowe hasło', 'private_messages_explanation' => 'Pozwól innym użytkownikom na wysyłanie wiadomości do mnie (bez udostępniania mojego adresu)', + 'private_messages_email_explanation' => 'Powiadamiaj mnie e-mailowo, gdy otrzymam wiadomość prywatną', 'private_messages' => 'Wiadomości prywatne:', + 'private_messages_email' => 'Powiadomienia o wiadomościach prywatnych:', 'profile_saved' => 'Profil zapisany', 'wall_posts' => "Ściana Wpisów:", 'wall_posts_explanation' => "Zezwalaj użytkownikom na zamieszczanie wiadomości na ścianie (będziesz informowany o wpisie pocztą email)", @@ -135,8 +137,8 @@ 'x_ago_from_y' => '^1 temu z ^2', 'terms_not_accepted' => "Musisz to zaznaczyć.", ); - + /* Omit PHP closing tag to help avoid accidental output -*/ \ No newline at end of file +*/