diff options
author | Malf Furious <m@lfurio.us> | 2018-11-10 09:12:01 -0500 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2018-11-10 09:12:01 -0500 |
commit | 762208664a9173bc9507a66fbd0c8020e382db88 (patch) | |
tree | 9b666f07a22a88228dc5c61a83845e273e4b4730 | |
parent | 0e3e65d1ba0ecbc4f819fed3eb9c03e212e400c1 (diff) | |
download | scrott-762208664a9173bc9507a66fbd0c8020e382db88.tar.gz scrott-762208664a9173bc9507a66fbd0c8020e382db88.zip |
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 <m@lfurio.us>
-rw-r--r-- | app/class/agent.class.php | 7 | ||||
-rw-r--r-- | app/class/group.class.php | 11 | ||||
-rw-r--r-- | app/class/user.class.php | 9 |
3 files changed, 27 insertions, 0 deletions
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 @@ -90,6 +90,13 @@ abstract class agent extends obj } /* + * 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 * attempted. Return status. 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 @@ -64,6 +64,17 @@ class group extends agent } /* + * 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 * attempted. Return status. If any delivery attempts fail, the 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 @@ -294,6 +294,15 @@ class user extends agent } /* + * 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 * attempted. Return status. |