1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-25 11:01:48 +02:00

[ticket/11103] Set basic notifications to be enabled by default

Now, if there is no row for the user in the user_notifications table,
the user will receive basic notifications. If the user wishes to not
receive notifications, a row must be added with notify = 0.

For other methods besides the basic (e.g. email, jabber) a row must
still be added with notify = 1 for them to receive notifications

PHPBB3-11103
This commit is contained in:
Nathan Guse
2012-10-29 18:09:20 -05:00
parent eddb56f842
commit e549b7663d
26 changed files with 219 additions and 483 deletions

View File

@@ -70,7 +70,7 @@ class phpbb_mock_notification_manager
}
public function get_subscriptions()
public function get_global_subscriptions()
{
return array();
}

View File

@@ -29,7 +29,7 @@ class phpbb_ext_test_notification_type_test extends phpbb_notification_type_base
public function find_users_for_notification($post, $options = array())
{
return $this->_find_users_for_notification(0, $options);
return $this->check_user_notification_options(array(0), $options);
}
public function create_insert_array($post, $pre_create_data = array())

View File

@@ -119,159 +119,19 @@ class phpbb_notification_test extends phpbb_database_test_case
public function test_subscriptions()
{
$this->notifications->add_subscription('phpbb_notification_type_post', 0, '');
$this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 1);
$this->notifications->add_subscription('phpbb_notification_type_quote', 0, '', 1);
$this->notifications->delete_subscription('phpbb_notification_type_post', 0, '', 2);
$this->assertArrayNotHasKey('phpbb_notification_type_post', $this->notifications->get_global_subscriptions(2));
$this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 0, 'email', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 0, 'jabber', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 1, '', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 1, 'email', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 1, 'jabber', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 2, '', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 2, 'email', 2);
$this->notifications->add_subscription('phpbb_notification_type_post', 2, 'jabber', 2);
$this->assertEquals(array(
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 0,
'method' => '',
),
), $this->notifications->get_subscriptions());
$this->assertEquals(array(
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 1,
'method' => '',
),
array(
'item_type' => 'phpbb_notification_type_quote',
'item_id' => 0,
'user_id' => 1,
'method' => '',
),
), $this->notifications->get_subscriptions(1));
$this->assertEquals(array(
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => '',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'email',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'jabber',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => '',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => 'email',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => 'jabber',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => '',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => 'email',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => 'jabber',
),
), $this->notifications->get_subscriptions(2));
$this->assertEquals(array(
'phpbb_notification_type_post' => array(
'',
'email',
'jabber',
),
), $this->notifications->get_subscriptions(2, true));
$this->notifications->delete_subscription('phpbb_notification_type_post', 0, '', 2);
$this->notifications->delete_subscription('phpbb_notification_type_post', 1, 'email', 2);
$this->notifications->delete_subscription('phpbb_notification_type_post', 2, 'jabber', 2);
$this->assertEquals(array(
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'email',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'jabber',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => '',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => 'jabber',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => '',
),
array(
'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => 'email',
),
), $this->notifications->get_subscriptions(2));
$this->assertArrayHasKey('phpbb_notification_type_post', $this->notifications->get_global_subscriptions(2));
}
public function test_notifications()
{
global $db;
$this->notifications->add_subscription('phpbb_ext_test_notification_type_test');
// Used to test post notifications later
$db->sql_query('INSERT INTO ' . TOPICS_WATCH_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'topic_id' => 2,
@@ -320,7 +180,6 @@ class phpbb_notification_test extends phpbb_database_test_case
'topic_id' => 2,
'user_id' => 0,
)));
$this->notifications->add_subscription('phpbb_notification_type_bookmark');
$this->notifications->add_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array(
'post_id' => '5',