From 12a4eb3a21fceb994906eed4a1bc6679cc06d8ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Lahmann?= <lahmann@ub.uni-leipzig.de>
Date: Thu, 1 Sep 2016 13:11:37 +0200
Subject: [PATCH] refs #8580: * use ILS patron data in pda email template (was
 db user data)

---
 module/finc/src/finc/Controller/PdaTrait.php | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/module/finc/src/finc/Controller/PdaTrait.php b/module/finc/src/finc/Controller/PdaTrait.php
index 61fc4085dfa..9e8e71a9a4f 100644
--- a/module/finc/src/finc/Controller/PdaTrait.php
+++ b/module/finc/src/finc/Controller/PdaTrait.php
@@ -89,15 +89,20 @@ trait PdaTrait
         // User is authorized to use PDA
 
         // Start collecting params for PDA
+        $catalog = $this->getILS();
+        $profile = $catalog->getMyProfile($patron);
+
+        // prefer profile data from ILS over user data from db
         $params = [
             'username'  => trim($user->cat_username),
-            'email'     => trim($user->email),
-            'firstname' => trim($user->firstname),
-            'lastname'  => trim($user->lastname)
+            'email'     => isset($profile['email'])
+                ? $profile['email'] : trim($user->email),
+            'firstname' => isset($profile['firstname'])
+                ? $profile['firstname'] : trim($user->firstname),
+            'lastname'  => isset($profile['lastname'])
+                ? $profile['lastname'] : trim($user->lastname)
         ];
 
-        $catalog = $this->getILS();
-        $profile = $catalog->getMyProfile($patron);
         if (isset($profile['group'])) {
             $params['group'] = $profile['group'];
         }
-- 
GitLab