Bugzilla – Attachment 166429 Details for
Bug 36815
Add the option to 'Reset to default' in the notices editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36815: Add 'get_default' method to Koha::Notice::Template
Bug-36815-Add-getdefault-method-to-KohaNoticeTempl.patch (text/plain), 2.51 KB, created by
Martin Renvoize
on 2024-05-08 16:08:42 UTC
(
hide
)
Description:
Bug 36815: Add 'get_default' method to Koha::Notice::Template
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-05-08 16:08:42 UTC
Size:
2.51 KB
patch
obsolete
>From 082c6759c329c2f8d53b4b62bec62ff142562c83 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 8 May 2024 16:19:26 +0100 >Subject: [PATCH] Bug 36815: Add 'get_default' method to Koha::Notice::Template > >This patch adds a new 'get_default' method to the Koha::Notice::Template >object. The idea is that it returns the template content as defined by >the sample_notices.yml file for the language of your choosing. >--- > Koha/Notice/Template.pm | 50 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) > >diff --git a/Koha/Notice/Template.pm b/Koha/Notice/Template.pm >index 76694816902..7da30e05d6c 100644 >--- a/Koha/Notice/Template.pm >+++ b/Koha/Notice/Template.pm >@@ -17,7 +17,9 @@ package Koha::Notice::Template; > > use Modern::Perl; > >+use YAML::XS qw(LoadFile); > >+use C4::Context; > use Koha::Database; > > use base qw(Koha::Object); >@@ -30,8 +32,56 @@ Koha::Notice::Template - Koha notice template Object class, related to the lette > > =head2 Class Methods > >+=head3 get_default >+ >+ my $default = $template->get_default; >+ >+Returns the default notice template content. >+ > =cut > >+sub get_default { >+ my $self = shift; >+ my $lang = $self->lang; >+ my $defaulted_to_en = 0; >+ >+ my $file = C4::Context->config('intranetdir') . "/installer/data/mysql/$lang/mandatory/sample_notices.yml"; >+ if ( !-e $file ) { >+ if ( $lang eq 'en' ) { >+ warn "cannot open sample data $file"; >+ } else { >+ >+ # if no localised sample data is available, >+ # default to English >+ $file = C4::Context->config('intranetdir') . "/installer/data/mysql/en/mandatory/sample_notices.yml"; >+ die "cannot open English sample data directory $file" unless ( -e $file ); >+ $defaulted_to_en = 1; >+ } >+ } >+ >+ my $data = YAML::XS::LoadFile("$file"); >+ >+ my $module = $self->module; >+ my $code = $self->code; >+ my $mtt = $self->message_transport_type; >+ >+ my $content; >+ for my $table ( @{ $data->{tables} } ) { >+ if ( $table->{letter}->{rows} ) { >+ for my $template ( @{ $table->{letter}->{rows} } ) { >+ if ( $template->{module} eq $module >+ && $template->{code} eq $code >+ && $template->{message_transport_type} eq $mtt ) >+ { >+ $content = join "\r\n", @{ $template->{content} }; >+ } >+ } >+ } >+ } >+ >+ return $content; >+} >+ > =head3 type > > =cut >-- >2.45.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36815
:
166429
|
166430
|
166449
|
166450
|
166475
|
166476
|
166535
|
166678
|
166679
|
166680
|
166684
|
166685
|
166686
|
166689
|
166693
|
166694
|
166695
|
166696
|
166763
|
166764
|
166765
|
166766
|
168190
|
168191
|
168192
|
168193
|
168194