From 96820a81fb94e9dc05c6bae3bf622e3d84577228 Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Wed, 10 Nov 2021 14:45:17 +0100 Subject: [PATCH] Bug 29393: Add send_messages_to_borrowers permission Signed-off-by: Matthias Le Gac Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- circ/add_message.pl | 5 +++++ .../Bug_29393_add_send_message_permission.pl | 14 ++++++++++++++ installer/data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/members-toolbar.inc | 4 +++- .../intranet-tmpl/prog/en/includes/permissions.inc | 5 +++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_29393_add_send_message_permission.pl diff --git a/circ/add_message.pl b/circ/add_message.pl index d7f8a2dff6..284c8de3fb 100755 --- a/circ/add_message.pl +++ b/circ/add_message.pl @@ -64,6 +64,11 @@ elsif( $op eq 'cud-add_message' ) { } if ( $message_type eq 'E' ) { + my $logged_in_patron = Koha::Patrons->find( $loggedinuser ); + if ( !$logged_in_patron->has_permission({ borrowers => 'send_messages_to_borrowers' }) ) { + C4::Output::output_and_exit( $input, $cookie, $template, 'insufficient_permission' ) + } + my $letter = { title => $borrower_subject, content => $borrower_message diff --git a/installer/data/mysql/atomicupdate/Bug_29393_add_send_message_permission.pl b/installer/data/mysql/atomicupdate/Bug_29393_add_send_message_permission.pl new file mode 100644 index 0000000000..12327f92be --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug_29393_add_send_message_permission.pl @@ -0,0 +1,14 @@ +use Modern::Perl; + +return { + bug_number => "29393", + description => "Add permission borrowers:send_messages_to_borrowers", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{INSERT INTO permissions (module_bit, code, description) + VALUES (4, 'send_messages_to_borrowers', 'Send messages to patrons')}); + say $out "Update is going well so far"; + }, +} diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index a132b83e20..4b5c8ebe2c 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -47,6 +47,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 4, 'delete_borrowers', 'Delete patrons'), ( 4, 'edit_borrowers', 'Add, modify and view patron information'), ( 4, 'list_borrowers', 'Search, list and view patrons'), + ( 4, 'send_messages_to_borrowers', 'Send messages to patrons'), ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), ( 6, 'place_holds', 'Place holds for patrons'), ( 6, 'modify_holds_priority', 'Modify holds priority'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 072f705b52..e1e6ab3a61 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -137,7 +137,9 @@ [% bor_notes = AuthorisedValues.Get( 'BOR_NOTES' ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 64accc2e85..a4efd4105f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -322,6 +322,11 @@ View patron infos from any libraries. If not set the logged in user could only access patron infos from its own library or group of libraries. ([% name | html %]) + [%- CASE 'send_messages_to_borrowers' -%] + + Send messages to patrons + + ([% name | html %]) [%- CASE 'modify_holds_priority' -%] Modify holds priority -- 2.39.5