From 762208664a9173bc9507a66fbd0c8020e382db88 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 10 Nov 2018 09:12:01 -0500 Subject: Add function agent::getContainedUsers() This function helps further abstract agents. We want to get all users belonging to a pad that is owned by a group, or more specifically - an agent. If this agent is a user, that user is our only user to collect. If this agent is a group, we want to capture _it's_ owner along with all of it's members. Signed-off-by: Malf Furious --- app/class/agent.class.php | 7 +++++++ app/class/group.class.php | 11 +++++++++++ app/class/user.class.php | 9 +++++++++ 3 files changed, 27 insertions(+) (limited to 'app') diff --git a/app/class/agent.class.php b/app/class/agent.class.php index 4c75f0b..4651a10 100644 --- a/app/class/agent.class.php +++ b/app/class/agent.class.php @@ -89,6 +89,13 @@ abstract class agent extends obj return false; } + /* + * Get all contained users. For users, this is an array containing + * only $this. For groups, this is an array containing the owner + * and all members. + */ + public abstract function getContainedUsers() : array; + /* * Send an email message to this agent using stored configuration * parameters. If config is not established, delivery is not diff --git a/app/class/group.class.php b/app/class/group.class.php index 1191d71..600fb6d 100644 --- a/app/class/group.class.php +++ b/app/class/group.class.php @@ -63,6 +63,17 @@ class group extends agent return $group; } + /* + * Get all contained users. This is an array of all members and + * the group owner. + */ + public function getContainedUsers() : array + { + $cus = $this->getMembers(); + $cus[] = $this->getOwner(); + return $cus; + } + /* * Send an email message to this group using stored configuration * parameters. If config is not established, delivery is not diff --git a/app/class/user.class.php b/app/class/user.class.php index 90aac44..231111d 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -293,6 +293,15 @@ class user extends agent return $groups; } + /* + * Get all contained users. This is just an array containing + * the user object. + */ + public function getContainedUsers() : array + { + return array($this); + } + /* * Send an email message to this user using stored configuration * parameters. If config is not established, delivery is not -- cgit v1.2.3 From be18c21941eb1309047e5cede3467cc538e71559 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 10 Nov 2018 09:21:54 -0500 Subject: Fix bug in assignee selection Previously, issues on pads owned by a group (rather than by a user) would incorrectly present options for user assignment. It would show the group as a member of the list, misleadingly with the user icon to the left of it. This patch uses the new agent::getContainedUsers() function to resolve the pad's owner to an array of users accessible via the owner 'agent'. Signed-off-by: Malf Furious --- app/view/issue.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/view/issue.php b/app/view/issue.php index 6edf7cf..01a9f5f 100644 --- a/app/view/issue.php +++ b/app/view/issue.php @@ -138,9 +138,11 @@ require_once "class/issue.class.php";