Skip to content
Snippets Groups Projects
Commit aa67e992 authored by Peter Rotich's avatar Peter Rotich
Browse files

Dept: Eliminate unnecessary lookup

Use dept_id provided with the assumption that the caller validated it- this
helps to avoid unnecessary database lookup.
parent 2a8b0bd8
No related branches found
No related tags found
No related merge requests found
...@@ -477,10 +477,13 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable { ...@@ -477,10 +477,13 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable {
if (is_null($dept)) if (is_null($dept))
return $this->role; return $this->role;
if ((!$dept instanceof Dept) && !($dept=Dept::lookup($dept))) if (is_numeric($dept))
return null; $deptId = $dept;
elseif($dept instanceof Dept)
$deptId = $dept->getId();
else
return null;
$deptId = $dept->getId();
$roles = $this->getRoles(); $roles = $this->getRoles();
if (isset($roles[$deptId])) if (isset($roles[$deptId]))
return $roles[$deptId]; return $roles[$deptId];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment