From 951d6f90d80e2eccf40af7908e426ece310d6b50 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 12:54:13 +0200
Subject: [PATCH] refs #8580: * added usergroup to pda email

---
 module/finc/src/finc/Controller/PdaTrait.php          | 11 +++++++++++
 themes/finc/templates/Email/acquisitionpda-html.phtml |  1 +
 .../finc/templates/Email/acquisitionpda-plain.phtml   |  2 ++
 3 files changed, 14 insertions(+)

diff --git a/module/finc/src/finc/Controller/PdaTrait.php b/module/finc/src/finc/Controller/PdaTrait.php
index 436d954bf4e..61fc4085dfa 100644
--- a/module/finc/src/finc/Controller/PdaTrait.php
+++ b/module/finc/src/finc/Controller/PdaTrait.php
@@ -62,6 +62,11 @@ trait PdaTrait
      */
     public function pdaAction()
     {
+        // Stop now if the user does not have valid catalog credentials available:
+        if (!is_array($patron = $this->catalogLogin())) {
+            return $patron;
+        }
+
         // Check with the set accessPermission if the user is authorized to use PDA
         $accessPermission = 'access.PDAForm';
 
@@ -91,6 +96,12 @@ trait PdaTrait
             'lastname'  => trim($user->lastname)
         ];
 
+        $catalog = $this->getILS();
+        $profile = $catalog->getMyProfile($patron);
+        if (isset($profile['group'])) {
+            $params['group'] = $profile['group'];
+        }
+
         // Create view
         $view = $this->createPDAEmailViewModel();
 
diff --git a/themes/finc/templates/Email/acquisitionpda-html.phtml b/themes/finc/templates/Email/acquisitionpda-html.phtml
index 6ad536d778b..9ee2862a249 100644
--- a/themes/finc/templates/Email/acquisitionpda-html.phtml
+++ b/themes/finc/templates/Email/acquisitionpda-html.phtml
@@ -12,6 +12,7 @@
             Name: <strong><?= $lastname ?>, <?= $firstname ?></strong><br/>
             Lesekarte-Nr.: <strong><?= $username ?></strong><br/>
             Email: <a href="mailto:<?= $email ?>"><?= $email ?></a><br/>
+            <?=isset($group) ? "Benutzergruppe: ". $group . "<br/>" : ""?>
             <br/>
             <? if ($statement): ?>
                 Begründung des Benutzers:
diff --git a/themes/finc/templates/Email/acquisitionpda-plain.phtml b/themes/finc/templates/Email/acquisitionpda-plain.phtml
index 9c4dbebda46..0fc6999aabc 100644
--- a/themes/finc/templates/Email/acquisitionpda-plain.phtml
+++ b/themes/finc/templates/Email/acquisitionpda-plain.phtml
@@ -6,6 +6,8 @@ Lesekarte-Nr.: <?= $username ?>
 
 Email: <?= $email ?>
 
+<?=isset($group) ? "Benutzergruppe: ". $group : ""?>
+
 hat folgenden Titel bestellt:
 
 <?= $title ?>
-- 
GitLab