From eddb56f8426161923d8870ca5f8f899c342075db Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Oct 2012 12:03:11 -0500 Subject: [PATCH] [ticket/11103] Working on default notifications on install/update PHPBB3-11103 --- phpBB/install/database_update.php | 105 +++++++++++++++++++++++++- phpBB/install/schemas/schema_data.sql | 11 +++ 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c24877fd74..3e4edc0b8f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -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; diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 0d47f4995e..28f8b1c3b6 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -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 #