Fix issue with notifications and projects that allow everybody
This commit is contained in:
@@ -35,6 +35,17 @@ class Notification extends Base
|
|||||||
*/
|
*/
|
||||||
public function getUsersWithNotification($project_id, array $exclude_users = array())
|
public function getUsersWithNotification($project_id, array $exclude_users = array())
|
||||||
{
|
{
|
||||||
|
if ($this->projectPermission->isEverybodyAllowed($project_id)) {
|
||||||
|
|
||||||
|
return $this->db
|
||||||
|
->table(User::TABLE)
|
||||||
|
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email')
|
||||||
|
->eq('notifications_enabled', '1')
|
||||||
|
->neq('email', '')
|
||||||
|
->notin(User::TABLE.'.id', $exclude_users)
|
||||||
|
->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(ProjectPermission::TABLE)
|
->table(ProjectPermission::TABLE)
|
||||||
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email')
|
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email')
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class NotificationTest extends Base
|
|||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||||
$this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
|
$this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
|
||||||
|
$this->assertEquals(3, $p->create(array('name' => 'UnitTest3', 'is_everybody_allowed' => 1)));
|
||||||
|
|
||||||
// Email + Notifications enabled
|
// Email + Notifications enabled
|
||||||
$this->assertTrue($u->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1)));
|
$this->assertTrue($u->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1)));
|
||||||
@@ -116,5 +117,17 @@ class NotificationTest extends Base
|
|||||||
$this->assertNotEmpty($users);
|
$this->assertNotEmpty($users);
|
||||||
$this->assertEquals(1, count($users));
|
$this->assertEquals(1, count($users));
|
||||||
$this->assertEquals('user3@here', $users[0]['email']);
|
$this->assertEquals('user3@here', $users[0]['email']);
|
||||||
|
|
||||||
|
// Project #3 allow everybody
|
||||||
|
$users = $n->getUsersList(3);
|
||||||
|
$this->assertNotEmpty($users);
|
||||||
|
$this->assertEquals(1, count($users));
|
||||||
|
$this->assertEquals('user1@here', $users[0]['email']);
|
||||||
|
|
||||||
|
$users = $n->getUsersWithNotification(3);
|
||||||
|
$this->assertNotEmpty($users);
|
||||||
|
$this->assertEquals(2, count($users));
|
||||||
|
$this->assertEquals('user1@here', $users[0]['email']);
|
||||||
|
$this->assertEquals('user3@here', $users[1]['email']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user