Subject: [PATCH] Bug 38773: SMTP server is not showing on the library detail page

From: Owen Leonard <[email-masked]>
Date: Thu, 30 Jan 2025 19:29:44 +0000

This patch fixes and incorrect template variable name, making it
possible to see a library's SMTP server when viewing the details of an
individual library.

Test plan copied from the original bug report:

1. Create an SMTP server in Koha (it doesn't need to be valid)
   a. Go to Administration -> Additional parameters -> SMTP servers
   b. Click "New STP server"
   c. Fill all mandatory fields (it doesn't need to be valid
      information)
   d. Click "Submit"

2. Add the created SMTP server to a library
   a. Go to Administration -> Basic parameters -> Libraries
   b. Choose a library and click on Edit (in column "Actions")
   c. On the line "SMTP server" select the server created
   d. Click "Submit"

3. Check the display
   a. Go to Administration -> Basic parameters -> Libraries
   b. Check that the name of the SMTP server you just selected is
      displayed in the column SMTP server
   c. Click on the name of the library you modified
   d. Check that the line "SMTP server" shows the correct information.

4. Test with different permissions
   a. If the logged-in user has both 'manage_libraries' and
      'manage_smtp_servers' permissions the SMTP server name should be
      liked to the edit form for that server.
   b. If the logged-in user has only 'manage_libraries' permission there
      should be no link.

Signed-off-by: Bo Gustavsson <[email-masked]>
---
 .../prog/en/modules/admin/branches.tt              | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
index 2cf88b2788..53ea81b2d6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
@@ -517,10 +517,16 @@
                         <span class="label">Return-Path: </span>
                         [% library.branchreturnpath | html %]
                     </li>
-                    <li>
-                        <span class="label">SMTP server: </span>
-                        [% smtp_server.name | html %]
-                    </li>
+                    [% IF ( library.smtp_server.id ) %]
+                        <li>
+                            <span class="label">SMTP server: </span>
+                            [% IF ( CAN_user_parameters_manage_smtp_servers ) %]
+                                <a href="/cgi-bin/koha/admin/smtp_servers.pl?op=edit_form&smtp_server_id=[% library.smtp_server.id | uri %]">[% library.smtp_server.name | html %]</a>
+                            [% ELSE %]
+                                [% library.smtp_server.name | html %]
+                            [% END %]
+                        </li>
+                    [% END %]
                     <li>
                         <span class="label">URL: </span>
                         [% IF ( library.branchurl ) %]
-- 
2.43.0