1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-29 10:39:19 +02:00

[ticket/11103] Working on default notifications on install/update

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-10-27 12:03:11 -05:00
parent 4874226b6e
commit eddb56f842
2 changed files with 115 additions and 1 deletions

View File

@ -2755,9 +2755,112 @@ function change_database_data(&$no_updates, $version)
$config->set('site_home_text', '');
}
if (!isset($config['load_notifications']))
if (true)//!isset($config['load_notifications']))
{
$config->set('load_notifications', 1);
// Convert notifications
$convert_notifications = array(
array(
'check' => ($config['allow_topic_notify']),
'item_type' => 'phpbb_notification_type_post',
),
array(
'check' => ($config['allow_forum_notify']),
'item_type' => 'phpbb_notification_type_topic',
),
array(
'check' => ($config['allow_bookmarks']),
'item_type' => 'phpbb_notification_type_bookmark',
),
array(
'check' => ($config['allow_privmsg']),
'item_type' => 'phpbb_notification_type_pm',
),
);
foreach ($convert_notifications as $convert_data)
{
if ($convert_data['check'])
{
$sql = 'SELECT user_id, user_notify_type
FROM ' . USERS_TABLE . '
WHERE user_notify = 1';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
_sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => '',
)), $errored, $error_ary);
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
{
_sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => 'phpbb_notification_method_email',
)), $errored, $error_ary);
}
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
{
_sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => 'phpbb_notification_method_jabber',
)), $errored, $error_ary);
}
}
$db->sql_freeresult($result);
}
}
/*
// Add default notifications
$default_notifications = array(
array(
'check' => ($config['allow_topic_notify']),
'item_type' => 'phpbb_notification_type_post',
),
array(
'check' => ($config['allow_forum_notify']),
'item_type' => 'phpbb_notification_type_topic',
),
array(
'check' => ($config['allow_bookmarks']),
'item_type' => 'phpbb_notification_type_bookmark',
),
array(
'check' => ($config['allow_privmsg']),
'item_type' => 'phpbb_notification_type_pm',
),
);
foreach ($default_notifications as $convert_data)
{
if ($convert_data['check'])
{
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . '
AND user_type <> ' . USER_IGNORE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
_sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => '',
)), $errored, $error_ary);
}
$db->sql_freeresult($result);
}
}*/
}
break;

View File

@ -770,4 +770,15 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mp3');
INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg');
INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm');
# User Notification Options (for first user)
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('report', 0, 2, '');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('needs_approval', 0, 2, '');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_bookmark', 0, 2, '');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_pm', 0, 2, '');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, '');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, 'phpbb_notification_method_email');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_quote', 0, 2, '');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, '');
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, 'phpbb_notification_method_email');
# POSTGRES COMMIT #