Handle notifications for group members attached to a project
This commit is contained in:
@@ -9,6 +9,7 @@ New features:
|
|||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
* Handle notification for group members attached to a project
|
||||||
* Return the highest role for a project when a user is member of multiple groups
|
* Return the highest role for a project when a user is member of multiple groups
|
||||||
* Show in user interface the saving state of the task
|
* Show in user interface the saving state of the task
|
||||||
* Add dropdown menu for subtasks, categories, swimlanes, columns, custom filters, task links and groups
|
* Add dropdown menu for subtasks, categories, swimlanes, columns, custom filters, task links and groups
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ class ProjectGroupRole extends Base
|
|||||||
*/
|
*/
|
||||||
public function getAssignableUsers($project_id)
|
public function getAssignableUsers($project_id)
|
||||||
{
|
{
|
||||||
return $this->db->table(self::TABLE)
|
return $this->db->table(User::TABLE)
|
||||||
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name')
|
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name')
|
||||||
->join(GroupMember::TABLE, 'group_id', 'group_id', self::TABLE)
|
->join(GroupMember::TABLE, 'user_id', 'id', User::TABLE)
|
||||||
->join(User::TABLE, 'id', 'user_id', GroupMember::TABLE)
|
->join(self::TABLE, 'group_id', 'group_id', GroupMember::TABLE)
|
||||||
->eq(self::TABLE.'.project_id', $project_id)
|
->eq(self::TABLE.'.project_id', $project_id)
|
||||||
->in(self::TABLE.'.role', array(Role::PROJECT_MANAGER, Role::PROJECT_MEMBER))
|
->in(self::TABLE.'.role', array(Role::PROJECT_MANAGER, Role::PROJECT_MEMBER))
|
||||||
->asc(User::TABLE.'.username')
|
->asc(User::TABLE.'.username')
|
||||||
|
|||||||
@@ -71,7 +71,17 @@ class UserNotification extends Base
|
|||||||
return $this->getEverybodyWithNotificationEnabled($exclude_user_id);
|
return $this->getEverybodyWithNotificationEnabled($exclude_user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getProjectMembersWithNotificationEnabled($project_id, $exclude_user_id);
|
$users = array();
|
||||||
|
$members = $this->getProjectUserMembersWithNotificationEnabled($project_id, $exclude_user_id);
|
||||||
|
$groups = $this->getProjectGroupMembersWithNotificationEnabled($project_id, $exclude_user_id);
|
||||||
|
|
||||||
|
foreach (array_merge($members, $groups) as $user) {
|
||||||
|
if (! isset($users[$user['id']])) {
|
||||||
|
$users[$user['id']] = $user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values($users);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,14 +152,14 @@ class UserNotification extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of project members with notification enabled
|
* Get a list of group members with notification enabled
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param integer $project_id Project id
|
* @param integer $project_id Project id
|
||||||
* @param integer $exclude_user_id User id to exclude
|
* @param integer $exclude_user_id User id to exclude
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getProjectMembersWithNotificationEnabled($project_id, $exclude_user_id)
|
private function getProjectUserMembersWithNotificationEnabled($project_id, $exclude_user_id)
|
||||||
{
|
{
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(ProjectUserRole::TABLE)
|
->table(ProjectUserRole::TABLE)
|
||||||
@@ -161,6 +171,19 @@ class UserNotification extends Base
|
|||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getProjectGroupMembersWithNotificationEnabled($project_id, $exclude_user_id)
|
||||||
|
{
|
||||||
|
return $this->db
|
||||||
|
->table(ProjectGroupRole::TABLE)
|
||||||
|
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email', User::TABLE.'.language', User::TABLE.'.notifications_filter')
|
||||||
|
->join(GroupMember::TABLE, 'group_id', 'group_id', ProjectGroupRole::TABLE)
|
||||||
|
->join(User::TABLE, 'id', 'user_id', GroupMember::TABLE)
|
||||||
|
->eq(ProjectGroupRole::TABLE.'.project_id', $project_id)
|
||||||
|
->eq(User::TABLE.'.notifications_enabled', '1')
|
||||||
|
->neq(User::TABLE.'.id', $exclude_user_id)
|
||||||
|
->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of project members with notification enabled
|
* Get a list of project members with notification enabled
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ use Kanboard\Model\TaskCreation;
|
|||||||
use Kanboard\Model\Subtask;
|
use Kanboard\Model\Subtask;
|
||||||
use Kanboard\Model\Comment;
|
use Kanboard\Model\Comment;
|
||||||
use Kanboard\Model\User;
|
use Kanboard\Model\User;
|
||||||
|
use Kanboard\Model\Group;
|
||||||
|
use Kanboard\Model\GroupMember;
|
||||||
use Kanboard\Model\File;
|
use Kanboard\Model\File;
|
||||||
use Kanboard\Model\Project;
|
use Kanboard\Model\Project;
|
||||||
use Kanboard\Model\ProjectPermission;
|
use Kanboard\Model\ProjectPermission;
|
||||||
use Kanboard\Model\Task;
|
use Kanboard\Model\Task;
|
||||||
use Kanboard\Model\ProjectUserRole;
|
use Kanboard\Model\ProjectUserRole;
|
||||||
|
use Kanboard\Model\ProjectGroupRole;
|
||||||
use Kanboard\Model\UserNotification;
|
use Kanboard\Model\UserNotification;
|
||||||
use Kanboard\Model\UserNotificationFilter;
|
use Kanboard\Model\UserNotificationFilter;
|
||||||
use Kanboard\Model\UserNotificationType;
|
use Kanboard\Model\UserNotificationType;
|
||||||
@@ -98,6 +101,42 @@ class UserNotificationTest extends Base
|
|||||||
$this->assertEquals(array(1), $settings['notification_projects']);
|
$this->assertEquals(array(1), $settings['notification_projects']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetGroupMembersWithNotificationEnabled()
|
||||||
|
{
|
||||||
|
$userModel = new User($this->container);
|
||||||
|
$groupModel = new Group($this->container);
|
||||||
|
$groupMemberModel = new GroupMember($this->container);
|
||||||
|
$projectModel = new Project($this->container);
|
||||||
|
$userNotificationModel = new UserNotification($this->container);
|
||||||
|
$projectGroupRole = new ProjectGroupRole($this->container);
|
||||||
|
$projectUserRole = new ProjectUserRole($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(2, $userModel->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1)));
|
||||||
|
$this->assertEquals(3, $userModel->create(array('username' => 'user2', 'email' => '', 'notifications_enabled' => 1)));
|
||||||
|
$this->assertEquals(4, $userModel->create(array('username' => 'user3')));
|
||||||
|
|
||||||
|
$this->assertEquals(1, $groupModel->create('G1'));
|
||||||
|
$this->assertEquals(2, $groupModel->create('G2'));
|
||||||
|
|
||||||
|
$this->assertTrue($groupMemberModel->addUser(1, 2));
|
||||||
|
$this->assertTrue($groupMemberModel->addUser(1, 3));
|
||||||
|
$this->assertTrue($groupMemberModel->addUser(1, 4));
|
||||||
|
$this->assertTrue($groupMemberModel->addUser(2, 2));
|
||||||
|
$this->assertTrue($groupMemberModel->addUser(2, 3));
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
|
||||||
|
|
||||||
|
$this->assertTrue($projectGroupRole->addGroup(1, 1, Role::PROJECT_MEMBER));
|
||||||
|
$this->assertTrue($projectGroupRole->addGroup(1, 2, Role::PROJECT_VIEWER));
|
||||||
|
|
||||||
|
$this->assertTrue($projectUserRole->addUser(1, 2, Role::PROJECT_MEMBER));
|
||||||
|
|
||||||
|
$users = $userNotificationModel->getUsersWithNotificationEnabled(1);
|
||||||
|
$this->assertCount(2, $users);
|
||||||
|
$this->assertEquals('user1', $users[0]['username']);
|
||||||
|
$this->assertEquals('user2', $users[1]['username']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetProjectMembersWithNotifications()
|
public function testGetProjectMembersWithNotifications()
|
||||||
{
|
{
|
||||||
$u = new User($this->container);
|
$u = new User($this->container);
|
||||||
|
|||||||
Reference in New Issue
Block a user