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

(-)a/C4/Context.pm (-2 / +4 lines)
Lines 364-372 sub multivalue_preference { Link Here
364
    my ( $self, $preference ) = @_;
364
    my ( $self, $preference ) = @_;
365
365
366
    my $syspref = $self->preference($preference) // q{};
366
    my $syspref = $self->preference($preference) // q{};
367
    my $values  = [ split qr{\|}, $syspref ];
368
367
369
    return $values;
368
    return [ split qr{\|}, $syspref ]
369
        if $syspref =~ qr{\|};
370
371
    return [ split qr{,}, $syspref ]
370
}
372
}
371
373
372
=head2 enable_syspref_cache
374
=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 1367-1373 Circulation: Link Here
1367
        -
1367
        -
1368
            - "The following article request formats are supported:"
1368
            - "The following article request formats are supported:"
1369
            - pref: ArticleRequestsSupportedFormats
1369
            - pref: ArticleRequestsSupportedFormats
1370
            - "(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.)"
1370
              multiple_sortable:
1371
                PHOTOCOPY: Photocopy
1372
                SCAN: Scan
1373
            - "The first listed format is selected by default when you request via the OPAC."
1371
1374
1372
1375
1373
    Item bundles:
1376
    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
                                    <li>
174
                                    <li>
167
                                        <label for="branchcode">Pickup library:</label>
175
                                        <label for="branchcode">Pickup library:</label>
Lines 295-312 $(document).ready( function() { Link Here
295
        }
303
        }
296
    });
304
    });
297
305
298
    // Initialize format(s)
299
    var supported_formats = "[% Koha.Preference('ArticleRequestsSupportedFormats') | html %]";
300
    if( !supported_formats.match(/PHOTOCOPY/) )
301
        $('#format option[value="PHOTOCOPY"]').remove();
302
    if( !supported_formats.match(/SCAN/) )
303
        $('#format option[value="SCAN"]').remove();
304
305
    if( $('#format option').length > 1 ) {
306
        // Select first listed format
307
        var first_format = supported_formats.split('|')[0].replace(/^\s*|\s*$/g, '');
308
        $('#format option[value="'+first_format+'"]').attr('selected', true);
309
    }
310
});
306
});
311
</script>
307
</script>
312
[% END %]
308
[% 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