From aa67e992ef449bb8b60dff62da77c55b8beb4f26 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Tue, 16 Apr 2019 18:30:13 +0000 Subject: [PATCH] Dept: Eliminate unnecessary lookup Use dept_id provided with the assumption that the caller validated it- this helps to avoid unnecessary database lookup. --- include/class.staff.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/class.staff.php b/include/class.staff.php index 7f2392b51..2b0471a4c 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -477,10 +477,13 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable { if (is_null($dept)) return $this->role; - if ((!$dept instanceof Dept) && !($dept=Dept::lookup($dept))) - return null; + if (is_numeric($dept)) + $deptId = $dept; + elseif($dept instanceof Dept) + $deptId = $dept->getId(); + else + return null; - $deptId = $dept->getId(); $roles = $this->getRoles(); if (isset($roles[$deptId])) return $roles[$deptId]; -- GitLab