Skip to content

Commit

Permalink
#1387 The last time we change something to the database for post
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed Oct 18, 2015
1 parent d1e56eb commit a9e5b58
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
$previous_comment_time = $db->result($result);

// Get any subscribed users that should be notified (banned users are excluded)
$result = $db->query('SELECT u.id, u.email, u.notify_with_post, u.language FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'thread_subscriptions AS s ON u.id=s.user_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id='.$cur_commenting['fid'].' AND fp.group_id=u.group_id) LEFT JOIN '.$db->prefix.'online AS o ON u.id=o.user_id LEFT JOIN '.$db->prefix.'bans AS b ON u.username=b.username WHERE b.username IS NULL AND COALESCE(o.logged, u.last_visit)>'.$previous_comment_time.' AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.thread_id='.$tid.' AND u.id!='.$luna_user['id']) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT u.id, u.email, u.notify_with_comment, u.language FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'thread_subscriptions AS s ON u.id=s.user_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id='.$cur_commenting['fid'].' AND fp.group_id=u.group_id) LEFT JOIN '.$db->prefix.'online AS o ON u.id=o.user_id LEFT JOIN '.$db->prefix.'bans AS b ON u.username=b.username WHERE b.username IS NULL AND COALESCE(o.logged, u.last_visit)>'.$previous_comment_time.' AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.thread_id='.$tid.' AND u.id!='.$luna_user['id']) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result)) {
require_once LUNA_ROOT.'include/email.php';

Expand Down Expand Up @@ -271,7 +271,7 @@

// We have to double check here because the templates could be missing
if (isset($notification_emails[$cur_subscriber['language']])) {
if ($cur_subscriber['notify_with_post'] == '0')
if ($cur_subscriber['notify_with_comment'] == '0')
luna_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][0], $notification_emails[$cur_subscriber['language']][1]);
else
luna_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][2], $notification_emails[$cur_subscriber['language']][3]);
Expand Down Expand Up @@ -317,7 +317,7 @@
// Should we send out notifications?
if ($luna_config['o_forum_subscriptions'] == '1') {
// Get any subscribed users that should be notified (banned users are excluded)
$result = $db->query('SELECT u.id, u.email, u.notify_with_post, u.language FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'forum_subscriptions AS s ON u.id=s.user_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id='.$cur_commenting['fid'].' AND fp.group_id=u.group_id) LEFT JOIN '.$db->prefix.'bans AS b ON u.username=b.username WHERE b.username IS NULL AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.forum_id='.$cur_commenting['fid'].' AND u.id!='.$luna_user['id']) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT u.id, u.email, u.notify_with_comment, u.language FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'forum_subscriptions AS s ON u.id=s.user_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id='.$cur_commenting['fid'].' AND fp.group_id=u.group_id) LEFT JOIN '.$db->prefix.'bans AS b ON u.username=b.username WHERE b.username IS NULL AND (fp.read_forum IS NULL OR fp.read_forum=1) AND s.forum_id='.$cur_commenting['fid'].' AND u.id!='.$luna_user['id']) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result)) {
require_once LUNA_ROOT.'include/email.php';

Expand Down Expand Up @@ -401,7 +401,7 @@

// We have to double check here because the templates could be missing
if (isset($notification_emails[$cur_subscriber['language']])) {
if ($cur_subscriber['notify_with_post'] == '0')
if ($cur_subscriber['notify_with_comment'] == '0')
luna_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][0], $notification_emails[$cur_subscriber['language']][1]);
else
luna_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][2], $notification_emails[$cur_subscriber['language']][3]);
Expand Down
3 changes: 2 additions & 1 deletion db_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function stripslashes_array($array) {
$db->add_field('groups', 'g_soft_delete_view', 'TINYINT(1)', false, 0, 'g_user_title') or error('Unable to add g_soft_delete_view field', __FILE__, __LINE__, $db->error());
$db->add_field('users', 'color_scheme', 'INT(25)', false, '2') or error('Unable to add column "color_scheme" to table "users"', __FILE__, __LINE__, $db->error());
$db->add_field('users', 'notify_pm', 'TINYINT(1)', false, '1', 'use_pm') or error('Unable to add column "notify_pm" to table "users"', __FILE__, __LINE__, $db->error());
$db->add_field('users', 'notify_pm_full', 'TINYINT(1)', false, '0', 'notify_with_post') or error('Unable to add column "num_pms" to table "users"', __FILE__, __LINE__, $db->error());
$db->add_field('users', 'notify_pm_full', 'TINYINT(1)', false, '0', 'notify_with_comment') or error('Unable to add column "num_pms" to table "users"', __FILE__, __LINE__, $db->error());
$db->add_field('users', 'num_pms', 'INT(10) UNSIGNED', false, '0', 'num_comments') or error('Unable to add column "num_pms" to table "users"', __FILE__, __LINE__, $db->error());
$db->add_field('users', 'use_pm', 'TINYINT(1)', false, '1', 'activate_key') or error('Unable to add column "use_pm" to table "users"', __FILE__, __LINE__, $db->error());
$db->drop_field($db->prefix.'forums', 'last_poster', 'VARCHAR(200)', true) or error('Unable to drop last_poster field', __FILE__, __LINE__, $db->error());
Expand Down Expand Up @@ -635,6 +635,7 @@ function stripslashes_array($array) {
$db->rename_field('threads', 'first_comment_id', 'first_comment_id', 'INT(10)');
$db->rename_field('reports', 'comment_id', 'comment_id', 'INT(10)');
$db->rename_field('search_matches', 'comment_id', 'comment_id', 'INT(10)');
$db->rename_field('search_matches', 'notify_with_post', 'notify_with_comment', 'TINYINT(1)');

build_config(0, 'o_topic_review');
build_config(2, 'o_thread_subscriptions', 'o_subscriptions');
Expand Down
2 changes: 1 addition & 1 deletion include/class/luna_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ public static function create_database($db_type, $db_host, $db_name, $db_usernam
'allow_null' => false,
'default' => '1'
),
'notify_with_post' => array(
'notify_with_comment' => array(
'datatype' => 'TINYINT(1)',
'allow_null' => false,
'default' => '0'
Expand Down
4 changes: 2 additions & 2 deletions include/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
class Version {
// See http://getluna.org/docs/version.php for more info
const LUNA_VERSION = '1.3-dev';
const LUNA_CORE_VERSION = '1.3.5095';
const LUNA_CORE_VERSION = '1.3.5096';
const LUNA_CORE_REVISION = '130d1';

// The Luna Core code name
const LUNA_CODE_NAME = 'denim';
const LUNA_CODE_NAME_SEM = 'Denim';

// The database version number, every change in the database requires this number to go one up
const LUNA_DB_VERSION = '90.64';
const LUNA_DB_VERSION = '90.65';

// The parser version number, every change to the parser requires this number to go one up
const LUNA_PARSER_VERSION = '11.2.0';
Expand Down
2 changes: 1 addition & 1 deletion notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if ($id < 2)
message(__('Bad request. The link you followed is incorrect, outdated or you are simply not allowed to hang around here.', 'luna'), false, '404 Not Found');

$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.facebook, u.msn, u.twitter, u.google, u.location, u.signature, u.disp_threads, u.disp_comments, u.email_setting, u.notify_with_post, u.auto_notify, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.dst, u.language, u.style, u.num_comments, u.last_comment, u.registered, u.registration_ip, u.admin_note, u.date_format, u.time_format, u.last_visit, u.color_scheme, u.accent, g.g_id, g.g_user_title, g.g_moderator FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.facebook, u.msn, u.twitter, u.google, u.location, u.signature, u.disp_threads, u.disp_comments, u.email_setting, u.notify_with_comment, u.auto_notify, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.dst, u.language, u.style, u.num_comments, u.last_comment, u.registered, u.registration_ip, u.admin_note, u.date_format, u.time_format, u.last_visit, u.color_scheme, u.accent, g.g_id, g.g_user_title, g.g_moderator FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message(__('Bad request. The link you followed is incorrect, outdated or you are simply not allowed to hang around here.', 'luna'), false, '404 Not Found');

Expand Down
2 changes: 1 addition & 1 deletion profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
if ($id < 2)
message(__('Bad request. The link you followed is incorrect, outdated or you are simply not allowed to hang around here.', 'luna'), false, '404 Not Found');

$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.facebook, u.msn, u.twitter, u.google, u.location, u.signature, u.disp_threads, u.disp_comments, u.email_setting, u.notify_with_post, u.auto_notify, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.dst, u.language, u.style, u.num_comments, u.last_comment, u.registered, u.registration_ip, u.admin_note, u.date_format, u.time_format, u.last_visit, u.color_scheme, u.accent, g.g_id, g.g_user_title, g.g_moderator FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.facebook, u.msn, u.twitter, u.google, u.location, u.signature, u.disp_threads, u.disp_comments, u.email_setting, u.notify_with_comment, u.auto_notify, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.dst, u.language, u.style, u.num_comments, u.last_comment, u.registered, u.registration_ip, u.admin_note, u.date_format, u.time_format, u.last_visit, u.color_scheme, u.accent, g.g_id, g.g_user_title, g.g_moderator FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message(__('Bad request. The link you followed is incorrect, outdated or you are simply not allowed to hang around here.', 'luna'), false, '404 Not Found');

Expand Down
4 changes: 2 additions & 2 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@
redirect('settings.php?id='.$id);
} else {

$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.facebook, u.msn, u.twitter, u.google, u.location, u.signature, u.disp_threads, u.disp_comments, u.use_pm, u.email_setting, u.notify_with_post, u.auto_notify, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.dst, u.language, u.style, u.num_comments, u.last_comment, u.registered, u.registration_ip, u.admin_note, u.date_format, u.time_format, u.last_visit, u.color_scheme, u.enforce_accent, u.adapt_time, u.accent, g.g_id, g.g_user_title, g.g_moderator FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.facebook, u.msn, u.twitter, u.google, u.location, u.signature, u.disp_threads, u.disp_comments, u.use_pm, u.email_setting, u.notify_with_comment, u.auto_notify, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.dst, u.language, u.style, u.num_comments, u.last_comment, u.registered, u.registration_ip, u.admin_note, u.date_format, u.time_format, u.last_visit, u.color_scheme, u.enforce_accent, u.adapt_time, u.accent, g.g_id, g.g_user_title, g.g_moderator FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message(__('Bad request. The link you followed is incorrect, outdated or you are simply not allowed to hang around here.', 'luna'), false, '404 Not Found');

Expand Down Expand Up @@ -611,7 +611,7 @@
'show_sig' => isset($_POST['form']['show_sig']) ? '1' : '0',
'use_pm' => isset($_POST['form']['use_pm']) ? '1' : '0',
'email_setting' => intval($_POST['form']['email_setting']),
'notify_with_post' => isset($_POST['form']['notify_with_post']) ? '1' : '0',
'notify_with_comment' => isset($_POST['form']['notify_with_comment']) ? '1' : '0',
'auto_notify' => isset($_POST['form']['auto_notify']) ? '1' : '0'
);

Expand Down
2 changes: 1 addition & 1 deletion themes/Fifteen/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
<div class="col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" name="form[notify_with_post]" value="1"<?php if ($user['notify_with_post'] == '1') echo ' checked' ?> />
<input type="checkbox" name="form[notify_with_comment]" value="1"<?php if ($user['notify_with_comment'] == '1') echo ' checked' ?> />
<?php _e('Include a plain text version of new comments in subscription notification emails.', 'luna') ?>
</label>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/Sixteen/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
<div class="col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" name="form[notify_with_post]" value="1"<?php if ($user['notify_with_post'] == '1') echo ' checked' ?> />
<input type="checkbox" name="form[notify_with_comment]" value="1"<?php if ($user['notify_with_comment'] == '1') echo ' checked' ?> />
<?php _e('Include a plain text version of new comments in subscription notification emails.', 'luna') ?>
</label>
</div>
Expand Down

0 comments on commit a9e5b58

Please sign in to comment.