Compare commits

...

4 Commits

Author SHA1 Message Date
Jonathan Druart 9a8ea2e46d Bug 29113: Fix random assignation 2 years ago
Jonathan Druart 264ac5fd2d Bug 29113: Hide code for additional contents and generate it 2 years ago
Mason James fb2e8e3450 Bug 29564: Use List::MoreUtils so SIP U16/Xenial does not break 2 years ago
Jonathan Druart af0ec1e715 Bug 29567: (bug 28445 follow-up) Restore cataloguing plugins 2 years ago
  1. 2
      C4/SIP/Sip/Configuration.pm
  2. 18
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt
  3. 3
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
  4. 21
      tools/additional-contents.pl

2
C4/SIP/Sip/Configuration.pm

@ -9,7 +9,7 @@ package C4::SIP::Sip::Configuration;
use strict;
use warnings;
use XML::Simple qw(:strict);
use List::Util qw(uniq);
use List::MoreUtils qw(uniq);
use C4::SIP::Sip qw(siplog);
use Koha::Libraries;

18
koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt

@ -178,20 +178,10 @@
<form id="add_additional_content" method="post" action="/cgi-bin/koha/tools/additional-contents.pl" class="validate">
<input type="hidden" name="op" value="add_validate" />
<input type="hidden" name="id" value="[% additional_content.idnew | html %]" />
<input type="hidden" name="category" value="[% category | html %]" />
<input type="hidden" name="code" value="[% additional_content.code | html %]" />
<fieldset class="rows">
<ol>
<li>
[% IF additional_content %]
<span class="label">Code:</span> [% additional_content.code | html %]
<input type="hidden" id="code" name="code" value="[% additional_content.code | html %]" />
[% ELSE %]
<label for="code" class="required">Code:</label>
<input type="text" id="code" name="code" size="20" maxlength="20" value="" required="required"/>
<span class="required">Required</span>
[% END %]
</li>
<li>
<label for="location">Display location:</label>
<select id="location" name="location">
@ -212,7 +202,7 @@
[% UNLESS languages.size %]
<li>
<label for="title" class="required">Title: </label>
<input id="title" size="100" maxlength="250" type="text" name="title" value="[% additional_content.title | html %]" required="required" class="required" /> <span class="required">Required</span>
<input id="title" size="100" maxlength="250" type="text" name="title_default" value="[% additional_content.title | html %]" required="required" class="required" /> <span class="required">Required</span>
</li>
[% END %]
<li>
@ -260,11 +250,11 @@
<ol>
<li style="list-style: none;">
<label for="title_[% language.lang | html %]">Title: </label>
<input id="title_[% language.lang| html %]" size="100" maxlength="250" type="text" name="title" value="[% translated_contents.item(language.lang).title | html %]">
<input id="title_[% language.lang| html %]" size="100" maxlength="250" type="text" name="title_[% language.lang | html %]" value="[% translated_contents.item(language.lang).title | html %]">
</li>
<li style="list-style: none;">
<label for="content_[% language.lang | html %]">Content: </label>
<textarea name="content" id="content_[% language.lang | html %]" data-lang="[% language.lang | html%]" cols="75" rows="10">[% translated_contents.item(language.lang).content | html %]</textarea>
<textarea name="content_[% language.lang | html %]" id="content_[% language.lang | html %]" data-lang="[% language.lang | html%]" cols="75" rows="10">[% translated_contents.item(language.lang).content | html %]</textarea>
<input type="hidden" name="lang" value="[% language.lang | html %]" />
</li>
</ol>

3
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt

@ -225,6 +225,7 @@
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/pages/batchMod.js") | $raw %]
[% INCLUDE 'select2.inc' %]
[% INCLUDE 'calendar.inc' %]
<script>
// Prepare array of all column headers, incrementing each index by
// two to accommodate control and title columns
@ -283,7 +284,7 @@
[%- UNLESS (too_many_items_process) -%]
[%- FOREACH subfield IN subfields -%]
[% SET mv = subfield.marc_value %]
[%- IF ( mv.type == 'text2' ) -%]
[%- IF ( mv.type == 'text_plugin' ) -%]
<!-- subfield[% subfield.tag | html %][% subfield.subfield | html %][% subfield.random | html %] -->
[% mv.javascript | $raw %]
[%- END -%]

21
tools/additional-contents.pl

@ -83,8 +83,6 @@ elsif ( $op eq 'add_validate' ) {
my $code = $cgi->param('code');
my $branchcode = $cgi->param('branchcode') || undef;
my @title = $cgi->multi_param('title');
my @content = $cgi->multi_param('content');
my @lang = $cgi->multi_param('lang');
my $expirationdate;
@ -107,9 +105,9 @@ elsif ( $op eq 'add_validate' ) {
my $number = $cgi->param('number');
my $success = 1;
for my $lang ( @lang ) {
my $title = shift @title;
my $content = shift @content;
for my $lang ( sort {$a ne 'default'} @lang ) { # Process 'default' first
my $title = $cgi->param( 'title_' . $lang );
my $content = $cgi->param( 'content_' . $lang );
my $additional_content = Koha::AdditionalContents->find(
{
category => $category,
@ -161,7 +159,7 @@ elsif ( $op eq 'add_validate' ) {
my $additional_content = Koha::AdditionalContent->new(
{
category => $category,
code => $code,
code => $code || 'tmp_code',
location => $location,
branchcode => $branchcode,
title => $title,
@ -173,7 +171,16 @@ elsif ( $op eq 'add_validate' ) {
borrowernumber => $borrowernumber,
}
)->store;
eval { $additional_content->store; };
eval {
$additional_content->store;
unless ($code) {
$additional_content->discard_changes;
$code = $category eq 'news'
? 'News_' . $additional_content->idnew
: $location . '_' . $additional_content->idnew;
$additional_content->code($code)->store;
}
};
if ($@) {
$success = 0;
push @messages, { type => 'error', code => 'error_on_insert' };

Loading…
Cancel
Save