View | Details | Raw Unified | Return to bug 36081
Collapse All | Expand All

(-)a/C4/Context.pm (-2 / +4 lines)
Lines 310-318 sub multivalue_preference { Link Here
310
    my ( $self, $preference ) = @_;
310
    my ( $self, $preference ) = @_;
311
311
312
    my $syspref = $self->preference($preference) // q{};
312
    my $syspref = $self->preference($preference) // q{};
313
    my $values  = [ split qr{\|}, $syspref ];
314
313
315
    return $values;
314
    return [ split qr{\|}, $syspref ]
315
        if $syspref =~ qr{\|};
316
317
    return [ split qr{,}, $syspref ]
316
}
318
}
317
319
318
=head2 enable_syspref_cache
320
=head2 enable_syspref_cache
(-)a/Koha/ArticleRequest.pm (-4 / +3 lines)
Lines 266-275 sub store { Link Here
266
    if ( !$self->in_storage ) {
266
    if ( !$self->in_storage ) {
267
        $self->created_on( dt_from_string() );
267
        $self->created_on( dt_from_string() );
268
    }
268
    }
269
    my $format = $self->format;
269
270
    if ( C4::Context->preference('ArticleRequestsSupportedFormats') !~ /\b$format\b/ ) {
270
    Koha::Exceptions::ArticleRequest::WrongFormat->throw
271
        Koha::Exceptions::ArticleRequest::WrongFormat->throw;
271
        unless grep { $_ eq $self->format } @{ C4::Context->multivalue_preference('ArticleRequestsSupportedFormats') };
272
    }
273
272
274
    return $self->SUPER::store;
273
    return $self->SUPER::store;
275
}
274
}
(-)a/Koha/Template/Plugin/Koha.pm (+5 lines)
Lines 71-76 sub Preference { Link Here
71
    return C4::Context->preference( $pref );
71
    return C4::Context->preference( $pref );
72
}
72
}
73
73
74
sub MultivaluePreference {
75
    my ( $self, $pref ) = @_;
76
    return C4::Context->multivalue_preference( $pref );
77
}
78
74
=head3 CSVDelimiter
79
=head3 CSVDelimiter
75
80
76
The delimiter option 'tabs' is stored in the DB as 'tabulation' to avoid issues
81
The delimiter option 'tabs' is stored in the DB as 'tabulation' to avoid issues
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +4 lines)
Lines 1403-1409 Circulation: Link Here
1403
        -
1403
        -
1404
            - "The following article request formats are supported:"
1404
            - "The following article request formats are supported:"
1405
            - pref: ArticleRequestsSupportedFormats
1405
            - pref: ArticleRequestsSupportedFormats
1406
            - ". Valid choices are currently: PHOTOCOPY and SCAN. Separate the supported formats by a vertical bar. The first listed format is selected by default when you request via the OPAC."
1406
              multiple_sortable:
1407
                PHOTOCOPY: Photocopy
1408
                SCAN: Scan
1409
            - "The first listed format is selected by default when you request via the OPAC."
1407
1410
1408
1411
1409
    Item bundles:
1412
    Item bundles:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt (-14 / +10 lines)
Lines 155-167 Link Here
155
                                        <input type="text" name="patron_notes" id="patron_notes" size="50"/>
155
                                        <input type="text" name="patron_notes" id="patron_notes" size="50"/>
156
                                    </li>
156
                                    </li>
157
157
158
                                    [% SET ArticleRequestsSupportedFormats = Koha.MultivaluePreference('ArticleRequestsSupportedFormats') %]
159
                                    [% IF ArticleRequestsSupportedFormats.size %]
158
                                    <li>
160
                                    <li>
159
                                        <label for="format">Format:</label>
161
                                        <label for="format">Format:</label>
160
                                        <select name="format" id="format">
162
                                        <select name="format" id="format">
161
                                            <option value="PHOTOCOPY">Photocopy</option>
163
                                            [% FOR format IN ArticleRequestsSupportedFormats %]
162
                                            <option value="SCAN">Digital scan</option>
164
                                                [% IF format == 'PHOTOCOPY' %]
165
                                                    <option value="PHOTOCOPY">Photocopy</option>
166
                                                [% ELSIF format == 'SCAN' %]
167
                                                    <option value="SCAN">Digital scan</option>
168
                                                [% END %]
169
                                            [% END %]
163
                                        </select>
170
                                        </select>
164
                                    </li>
171
                                    </li>
172
                                    [% END %]
165
173
166
                                    [% IF AllPublicBranches.size > 1 %]
174
                                    [% IF AllPublicBranches.size > 1 %]
167
                                        <li>
175
                                        <li>
Lines 299-316 $(document).ready( function() { Link Here
299
        }
307
        }
300
    });
308
    });
301
309
302
    // Initialize format(s)
303
    var supported_formats = "[% Koha.Preference('ArticleRequestsSupportedFormats') | html %]";
304
    if( !supported_formats.match(/PHOTOCOPY/) )
305
        $('#format option[value="PHOTOCOPY"]').remove();
306
    if( !supported_formats.match(/SCAN/) )
307
        $('#format option[value="SCAN"]').remove();
308
309
    if( $('#format option').length > 1 ) {
310
        // Select first listed format
311
        var first_format = supported_formats.split('|')[0].replace(/^\s*|\s*$/g, '');
312
        $('#format option[value="'+first_format+'"]').attr('selected', true);
313
    }
314
});
310
});
315
</script>
311
</script>
316
[% END %]
312
[% END %]
(-)a/t/Context.t (-2 / +4 lines)
Lines 60-66 subtest 'yaml_preference() tests' => sub { Link Here
60
60
61
subtest 'multivalue_preference() tests' => sub {
61
subtest 'multivalue_preference() tests' => sub {
62
62
63
    plan tests => 3;
63
    plan tests => 4;
64
64
65
    t::lib::Mocks::mock_preference( 'MultiValuedSyspref', '' );
65
    t::lib::Mocks::mock_preference( 'MultiValuedSyspref', '' );
66
    is_deeply( C4::Context->multivalue_preference('MultiValuedSyspref'), [] );
66
    is_deeply( C4::Context->multivalue_preference('MultiValuedSyspref'), [] );
Lines 70-75 subtest 'multivalue_preference() tests' => sub { Link Here
70
70
71
    t::lib::Mocks::mock_preference( 'MultiValuedSyspref', 'some|more|values' );
71
    t::lib::Mocks::mock_preference( 'MultiValuedSyspref', 'some|more|values' );
72
    is_deeply( C4::Context->multivalue_preference('MultiValuedSyspref'), [ 'some', 'more', 'values' ] );
72
    is_deeply( C4::Context->multivalue_preference('MultiValuedSyspref'), [ 'some', 'more', 'values' ] );
73
74
    t::lib::Mocks::mock_preference( 'MultiValuedSyspref', 'some,more,values' );
75
    is_deeply( C4::Context->multivalue_preference('MultiValuedSyspref'), [ 'some', 'more', 'values' ] );
73
};
76
};
74
77
75
subtest 'needs_install() tests' => sub {
78
subtest 'needs_install() tests' => sub {
76
- 

Return to bug 36081