Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dump/forum.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
Expand All @@ -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\Z�8',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','����<��fW8�W���T���',50,'2016-05-16 20:07:05',3232264193,'2016-05-16 20:07:29',3232264193,'','mav5hhhz',NULL,0,0,NULL),(5,'2016-05-16 20:07:49',3232264193,'ekspert@example.com','ekspert',NULL,NULL,NULL,'zz80g8had7kjgyo2','$ m!�9]cV4��v6W�X3',20,'2016-05-16 20:07:49',3232264193,'2016-05-16 20:08:04',3232264193,'','q1ppwkra',NULL,0,0,NULL),(6,'2016-05-16 20:08:28',3232264193,'ekspertkategoria@example.com','ekspertkategoria',NULL,NULL,NULL,'bw1jyz4ms35w552p','~5�\"2��Ҷ��DS��\0',0,'2016-05-16 20:08:28',3232264193,'2016-05-16 20:08:52',3232264193,'','o58vm26q',NULL,0,0,NULL),(7,'2016-05-16 20:18:58',3232264193,'user@example.com','user',NULL,NULL,NULL,'vocuht4kfzgvuq6g','ήz��İ�f�2�`E���<',0,'2016-05-16 20:18:58',3232264193,'2016-05-16 20:19:12',3232264193,'','nbowefw3',NULL,0,0,NULL);
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,1,0,NULL),(2,'2016-05-16 20:03:13',3232264193,'admin@example.com','admin',NULL,NULL,NULL,'7tys2ocm8ed0k5kg','}��ׯ\Z߿���Ɵ���M\Z�8',100,'2016-05-16 20:04:55',3232264193,'2016-05-16 20:05:23',3232264193,'','xzolja3l',NULL,0,1,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,1,0,NULL),(4,'2016-05-16 20:07:05',3232264193,'redaktor@example.com','redaktor',NULL,NULL,NULL,'yzxqtbvtpynomair','����<��fW8�W���T���',50,'2016-05-16 20:07:05',3232264193,'2016-05-16 20:07:29',3232264193,'','mav5hhhz',NULL,0,1,0,NULL),(5,'2016-05-16 20:07:49',3232264193,'ekspert@example.com','ekspert',NULL,NULL,NULL,'zz80g8had7kjgyo2','$ m!�9]cV4��v6W�X3',20,'2016-05-16 20:07:49',3232264193,'2016-05-16 20:08:04',3232264193,'','q1ppwkra',NULL,0,1,0,NULL),(6,'2016-05-16 20:08:28',3232264193,'ekspertkategoria@example.com','ekspertkategoria',NULL,NULL,NULL,'bw1jyz4ms35w552p','~5�\"2��Ҷ��DS��\0',0,'2016-05-16 20:08:28',3232264193,'2016-05-16 20:08:52',3232264193,'','o58vm26q',NULL,0,1,0,NULL),(7,'2016-05-16 20:18:58',3232264193,'user@example.com','user',NULL,NULL,NULL,'vocuht4kfzgvuq6g','ήz��İ�f�2�`E���<',0,'2016-05-16 20:18:58',3232264193,'2016-05-16 20:19:12',3232264193,'','nbowefw3',NULL,0,1,0,NULL);
/*!40000 ALTER TABLE `qa_users` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -1166,4 +1167,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-05-16 20:34:10
-- Dump completed on 2016-07-04 21:37:19
3 changes: 2 additions & 1 deletion forum/qa-include/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function qa_db_table_definitions()
'sessioncode' => '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)',
Expand Down Expand Up @@ -1498,4 +1499,4 @@ function qa_db_upgrade_progress($text)

/*
Omit PHP closing tag to help avoid accidental output
*/
*/
4 changes: 2 additions & 2 deletions forum/qa-include/db/selects.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
*/
*/
4 changes: 3 additions & 1 deletion forum/qa-include/lang/qa-lang-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -139,4 +141,4 @@

/*
Omit PHP closing tag to help avoid accidental output
*/
*/
13 changes: 13 additions & 0 deletions forum/qa-include/pages/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);

Expand Down Expand Up @@ -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"',
Expand Down
43 changes: 25 additions & 18 deletions forum/qa-include/pages/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Można to zrobić bardziej elegancko.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To kod Q2A, ja tego nie pisałem a jedynie dodałem warunek - jakby więc poprawiać cały ich kod to na pewno wiele rzeczy można zrobić bardziej elegancko.

$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'],
Expand Down Expand Up @@ -240,4 +247,4 @@

/*
Omit PHP closing tag to help avoid accidental output
*/
*/
6 changes: 4 additions & 2 deletions forum/qa-lang/pl/qa-lang-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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
*/
*/