Handle notifications for group members attached to a project
This commit is contained in:
@@ -101,10 +101,10 @@ class ProjectGroupRole extends Base
|
||||
*/
|
||||
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')
|
||||
->join(GroupMember::TABLE, 'group_id', 'group_id', self::TABLE)
|
||||
->join(User::TABLE, 'id', 'user_id', GroupMember::TABLE)
|
||||
->join(GroupMember::TABLE, 'user_id', 'id', User::TABLE)
|
||||
->join(self::TABLE, 'group_id', 'group_id', GroupMember::TABLE)
|
||||
->eq(self::TABLE.'.project_id', $project_id)
|
||||
->in(self::TABLE.'.role', array(Role::PROJECT_MANAGER, Role::PROJECT_MEMBER))
|
||||
->asc(User::TABLE.'.username')
|
||||
|
||||
@@ -71,7 +71,17 @@ class UserNotification extends Base
|
||||
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
|
||||
* @param integer $project_id Project id
|
||||
* @param integer $exclude_user_id User id to exclude
|
||||
* @return array
|
||||
*/
|
||||
private function getProjectMembersWithNotificationEnabled($project_id, $exclude_user_id)
|
||||
private function getProjectUserMembersWithNotificationEnabled($project_id, $exclude_user_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(ProjectUserRole::TABLE)
|
||||
@@ -161,6 +171,19 @@ class UserNotification extends Base
|
||||
->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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user