From 173b002d3f9de83f93fc1a0128febcc44410c3d0 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 26 Mar 2017 04:14:58 -0400 Subject: Add function agent::getDisplayName() --- app/class/agent.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app') diff --git a/app/class/agent.class.php b/app/class/agent.class.php index 52bfc1e..038c485 100644 --- a/app/class/agent.class.php +++ b/app/class/agent.class.php @@ -50,6 +50,24 @@ abstract class agent extends object return false; } + /* + * Get the display name for this agent. For groups this is the + * object name; for users, this is the object name, unless an + * alias is set. + */ + public function getDisplayName() : string + { + if ($this->objtype != "user") + return $this->name; + + $user = new user($this->guid); + + if ($user->alias != "") + return $user->alias; + + return $user->name; + } + /* * Check whether this agent has access permission for given * object -- cgit v1.2.3