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

(-)a/opac/opac-shelves.pl (-4 / +7 lines)
Lines 148-154 if ( $op eq 'add_form' ) { Link Here
148
    if ( $shelf ) {
148
    if ( $shelf ) {
149
        $op = $referer;
149
        $op = $referer;
150
        my $sortfield = $query->param('sortfield');
150
        my $sortfield = $query->param('sortfield');
151
        $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
151
        $sortfield = 'title'
152
            unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
152
        if ( $shelf->can_be_managed( $loggedinuser ) ) {
153
        if ( $shelf->can_be_managed( $loggedinuser ) ) {
153
            $shelf->shelfname( scalar $query->param('shelfname') );
154
            $shelf->shelfname( scalar $query->param('shelfname') );
154
            $shelf->sortfield( $sortfield );
155
            $shelf->sortfield( $sortfield );
Lines 315-326 if ( $op eq 'view' ) { Link Here
315
316
316
            # By default order descending if sorting by dateaccessioned
317
            # By default order descending if sorting by dateaccessioned
317
            if ( $query->param('direction') ) {
318
            if ( $query->param('direction') ) {
318
               $direction = $query->param('direction');
319
                $direction = $query->param('direction');
319
            } elsif ( $sortfield eq 'dateaccessioned' and !$query->param('direction') ) {
320
            } elsif ( $sortfield eq 'dateaccessioned' and !$query->param('direction') ) {
320
               $direction = 'desc';
321
                $direction = 'desc';
321
            }
322
            }
322
            $direction = 'asc' if !$direction or ( $direction ne 'asc' and $direction ne 'desc' );
323
            $direction = 'asc' if !$direction or ( $direction ne 'asc' and $direction ne 'desc' );
323
            $sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
324
            $sortfield = 'title'
325
                if !$sortfield
326
                or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
324
327
325
            my $rows;
328
            my $rows;
326
            if ( $query->param('print') or $query->param('rss') ) {
329
            if ( $query->param('print') or $query->param('rss') ) {
(-)a/virtualshelves/shelves.pl (-4 / +9 lines)
Lines 120-126 if ( $op eq 'add_form' ) { Link Here
120
    if ( $shelf ) {
120
    if ( $shelf ) {
121
        $op = $referer;
121
        $op = $referer;
122
        my $sortfield = $query->param('sortfield');
122
        my $sortfield = $query->param('sortfield');
123
        $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
123
        $sortfield = 'title'
124
            unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
124
        if ( $shelf->can_be_managed( $loggedinuser ) ) {
125
        if ( $shelf->can_be_managed( $loggedinuser ) ) {
125
            $shelf->shelfname( scalar $query->param('shelfname') );
126
            $shelf->shelfname( scalar $query->param('shelfname') );
126
            $shelf->sortfield( $sortfield );
127
            $shelf->sortfield( $sortfield );
Lines 277-284 if ( $op eq 'view' ) { Link Here
277
    $shelf = Koha::Virtualshelves->find($shelfnumber);
278
    $shelf = Koha::Virtualshelves->find($shelfnumber);
278
    if ( $shelf ) {
279
    if ( $shelf ) {
279
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
280
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
280
            my $sortfield = $query->param('sortfield') || $shelf->sortfield || 'title';    # Passed in sorting overrides default sorting
281
            my $sortfield =
281
            $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
282
                   $query->param('sortfield')
283
                || $shelf->sortfield
284
                || 'title';    # Passed in sorting overrides default sorting
285
            $sortfield = 'title'
286
                unless grep { $_ eq $sortfield }
287
                qw( title author copyrightdate itemcallnumber dateadded dateaccessioned );
282
            my $direction = $query->param('direction') || 'asc';
288
            my $direction = $query->param('direction') || 'asc';
283
            $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc';
289
            $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc';
284
290
285
- 

Return to bug 36188