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

(-)a/C4/Auth.pm (-15 / +29 lines)
Lines 226-238 sub get_template_and_user { Link Here
226
        $template->param( sessionID          => $sessionID );
226
        $template->param( sessionID          => $sessionID );
227
227
228
        if ( $in->{'type'} eq 'opac' ) {
228
        if ( $in->{'type'} eq 'opac' ) {
229
            require C4::VirtualShelves;
229
            require Koha::Virtualshelves;
230
            my ( $total, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $borrowernumber, 'MASTHEAD' );
230
            my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
231
                {
232
                    borrowernumber => $borrowernumber,
233
                    category       => 1,
234
                }
235
            );
236
            my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
237
                {
238
                    category       => 2,
239
                }
240
            );
231
            $template->param(
241
            $template->param(
232
                pubshelves     => $total->{pubtotal},
242
                some_private_shelves => $some_private_shelves,
233
                pubshelvesloop => $pubshelves,
243
                some_public_shelves  => $some_public_shelves,
234
                barshelves     => $total->{bartotal},
235
                barshelvesloop => $barshelves,
236
            );
244
            );
237
        }
245
        }
238
246
Lines 363-373 sub get_template_and_user { Link Here
363
        $template->param( sessionID => $sessionID );
371
        $template->param( sessionID => $sessionID );
364
372
365
        if ( $in->{'type'} eq 'opac' ){
373
        if ( $in->{'type'} eq 'opac' ){
366
            require C4::VirtualShelves;
374
            require Koha::Virtualshelves;
367
            my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' );
375
            my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
376
                {
377
                    category       => 2,
378
                }
379
            );
368
            $template->param(
380
            $template->param(
369
                pubshelves     => $total->{pubtotal},
381
                some_public_shelves  => $some_public_shelves,
370
                pubshelvesloop => $pubshelves,
371
            );
382
            );
372
        }
383
        }
373
    }
384
    }
Lines 739-745 sub checkauth { Link Here
739
    # state variables
750
    # state variables
740
    my $loggedin = 0;
751
    my $loggedin = 0;
741
    my %info;
752
    my %info;
742
    my ( $userid, $cookie, $sessionID, $flags, $barshelves, $pubshelves );
753
    my ( $userid, $cookie, $sessionID, $flags );
743
    my $logout = $query->param('logout.x');
754
    my $logout = $query->param('logout.x');
744
755
745
    my $anon_search_history;
756
    my $anon_search_history;
Lines 1232-1242 sub checkauth { Link Here
1232
    $template->param( loginprompt => 1 ) unless $info{'nopermission'};
1243
    $template->param( loginprompt => 1 ) unless $info{'nopermission'};
1233
1244
1234
    if ( $type eq 'opac' ) {
1245
    if ( $type eq 'opac' ) {
1235
        require C4::VirtualShelves;
1246
        require Koha::Virtualshelves;
1236
        my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' );
1247
        my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
1248
            {
1249
                category       => 2,
1250
            }
1251
        );
1237
        $template->param(
1252
        $template->param(
1238
            pubshelves     => $total->{pubtotal},
1253
            some_public_shelves  => $some_public_shelves,
1239
            pubshelvesloop => $pubshelves,
1240
        );
1254
        );
1241
    }
1255
    }
1242
1256
(-)a/C4/VirtualShelves.pm (-39 lines)
Lines 63-107 bibs to and from virtual shelves. Link Here
63
63
64
=head1 FUNCTIONS
64
=head1 FUNCTIONS
65
65
66
=head2 GetSomeShelfNames
67
68
Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header.
69
70
=cut
71
72
sub GetSomeShelfNames {
73
    my ($owner, $purpose, $adding_allowed)= @_;
74
    my ($bar, $pub, @params);
75
    my $dbh = C4::Context->dbh;
76
77
    my $bquery = 'SELECT vs.shelfnumber, vs.shelfname FROM virtualshelves vs ';
78
    my $limit= ShelvesMax($purpose);
79
80
    my $qry1= $bquery."WHERE vs.category=2 ";
81
    $qry1.= "AND (allow_add=1 OR owner=?) " if $adding_allowed;
82
    push @params, $owner||0 if $adding_allowed;
83
    $qry1.= "ORDER BY vs.lastmodified DESC LIMIT $limit";
84
85
    unless($adding_allowed && (!defined($owner) || $owner<=0)) {
86
        #if adding items, user should be known
87
        $pub= $dbh->selectall_arrayref($qry1,{Slice=>{}},@params);
88
    }
89
90
    if($owner) {
91
        my $qry2= $bquery. qq{
92
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber AND sh.borrowernumber=?
93
            WHERE vs.category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
94
        @params=($owner,$owner,$owner);
95
        $qry2.= "AND (allow_add=1 OR owner=?) " if $adding_allowed;
96
        push @params, $owner if $adding_allowed;
97
        $qry2.= "ORDER BY vs.lastmodified DESC ";
98
        $qry2.= "LIMIT $limit";
99
        $bar= $dbh->selectall_arrayref($qry2,{Slice=>{}},@params);
100
    }
101
102
    return ( { bartotal => $bar? scalar @$bar: 0, pubtotal => $pub? scalar @$pub: 0}, $pub, $bar);
103
}
104
105
=head2 ShelvesMax
66
=head2 ShelvesMax
106
67
107
    $howmany= ShelvesMax($context);
68
    $howmany= ShelvesMax($context);
(-)a/Koha/Virtualshelves.pm (+39 lines)
Lines 80-85 sub get_public_shelves { Link Here
80
    );
80
    );
81
}
81
}
82
82
83
sub get_some_shelves {
84
    my ( $self, $params ) = @_;
85
    my $borrowernumber = $params->{borrowernumber} || 0;
86
    my $category = $params->{category} || 1;
87
    my $add_allowed = $params->{add_allowed};
88
89
    my @conditions;
90
    if ( $add_allowed ) {
91
        push @conditions, {
92
            -or =>
93
            {
94
                "me.allow_add" => 1,
95
                "me.owner" => $borrowernumber,
96
            }
97
        };
98
    }
99
    if ( $category == 1 ) {
100
        push @conditions, {
101
            -or =>
102
            {
103
                "virtualshelfshares.borrowernumber" => $borrowernumber,
104
                "me.owner" => $borrowernumber,
105
            }
106
        };
107
    }
108
109
    $self->search(
110
        {
111
            category => $category,
112
            ( @conditions ? ( -and => \@conditions ) : () ),
113
        },
114
        {
115
            join => [ 'virtualshelfshares' ],
116
            group_by => 'shelfnumber',
117
            order_by => 'lastmodified desc',
118
        }
119
    );
120
}
121
83
sub type {
122
sub type {
84
    return 'Virtualshelve';
123
    return 'Virtualshelve';
85
}
124
}
(-)a/catalogue/search.pl (-8 / +21 lines)
Lines 153-158 use POSIX qw(ceil floor); Link Here
153
use C4::Branch; # GetBranches
153
use C4::Branch; # GetBranches
154
use C4::Search::History;
154
use C4::Search::History;
155
155
156
use Koha::Virtualshelves;
157
156
use URI::Escape;
158
use URI::Escape;
157
159
158
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
160
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
Lines 746-759 if ($query_desc || $limit_desc) { Link Here
746
748
747
# VI. BUILD THE TEMPLATE
749
# VI. BUILD THE TEMPLATE
748
750
749
# Build drop-down list for 'Add To:' menu...
751
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
750
my ($totalref, $pubshelves, $barshelves)=
752
    {
751
	C4::VirtualShelves::GetSomeShelfNames($borrowernumber,'COMBO',1);
753
        borrowernumber => $borrowernumber,
754
        add_allowed    => 1,
755
        category       => 1,
756
    }
757
);
758
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
759
    {
760
        borrowernumber => $borrowernumber,
761
        add_allowed    => 1,
762
        category       => 2,
763
    }
764
);
765
766
752
$template->param(
767
$template->param(
753
        addbarshelves     => $totalref->{bartotal},
768
    add_to_some_private_shelves => $some_private_shelves,
754
        addbarshelvesloop => $barshelves,
769
    add_to_some_public_shelves  => $some_public_shelves,
755
	addpubshelves     => $totalref->{pubtotal},
770
);
756
	addpubshelvesloop => $pubshelves,
757
	);
758
771
759
output_html_with_http_headers $cgi, $cookie, $template->output;
772
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/installer/data/mysql/kohastructure.sql (-3 / +3 lines)
Lines 2304-2310 CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) Link Here
2304
  `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2304
  `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2305
  `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
2305
  `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
2306
  PRIMARY KEY  (`shelfnumber`),
2306
  PRIMARY KEY  (`shelfnumber`),
2307
  CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
2307
  CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
2308
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2308
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2309
2309
2310
--
2310
--
Lines 2322-2328 CREATE TABLE `virtualshelfcontents` ( -- information about the titles in a list Link Here
2322
  KEY `biblionumber` (`biblionumber`),
2322
  KEY `biblionumber` (`biblionumber`),
2323
  CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2323
  CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2324
  CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2324
  CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2325
  CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
2325
  CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
2326
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2326
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2327
2327
2328
--
2328
--
Lines 2337-2343 CREATE TABLE `virtualshelfshares` ( -- shared private lists Link Here
2337
  `invitekey` varchar(10), -- temporary string used in accepting the invitation to access thist list; not-empty means that the invitation has not been accepted yet
2337
  `invitekey` varchar(10), -- temporary string used in accepting the invitation to access thist list; not-empty means that the invitation has not been accepted yet
2338
  `sharedate` datetime,  -- date of invitation or acceptance of invitation
2338
  `sharedate` datetime,  -- date of invitation or acceptance of invitation
2339
  CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2339
  CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2340
  CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm
2340
  CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
2341
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2341
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2342
2342
2343
--
2343
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-10 / +31 lines)
Lines 91-107 $('#sort_by').change(function() { Link Here
91
    });
91
    });
92
        var param1 = "<label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
92
        var param1 = "<label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
93
        [% IF ( intranetbookbag ) %]     param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>"; [% END %]
93
        [% IF ( intranetbookbag ) %]     param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>"; [% END %]
94
        [% IF ( virtualshelves ) %][% IF ( addbarshelves ) %]
94
95
        param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %]
95
        [% IF Koha.Preference('virtualshelves') %]
96
        param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %]
96
            [% IF add_to_some_private_shelves.count %]
97
        param1 += "<\/optgroup>";[% END %]
97
                param1 += "<optgroup label=\""+_("Your lists:")+"\">";
98
        [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %]
98
                [% SET number_of_private_shelves = 0 %]
99
        param1 += "<\/optgroup>";[% END %]
99
                [% FOREACH s IN add_to_some_private_shelves %]
100
        [% IF ( ( addbarshelvesloop && addbarshelvesloop.size>9 ) || (addpubshelvesloop && addpubshelvesloop.size>9 )) %]
100
                    [% IF shelfnumber != s.shelfnumber %]
101
            param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
101
                        param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
102
        [% END %]
102
                        [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
103
        param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
103
                        [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
104
                    [% END %]
105
                [% END %]
106
                param1 += "<\/optgroup>";
107
            [% END %]
108
            [% IF add_to_some_public_shelves.count %]
109
                param1 += "<optgroup label=\""+_("Public lists:")+"\">";
110
                [% SET number_of_public_shelves = 0 %]
111
                [% FOREACH s IN add_to_some_public_shelves %]
112
                    [% IF shelfnumber != s.shelfnumber %]
113
                        param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
114
                        [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
115
                        [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
116
                    [% END %]
117
                [% END %]
118
                param1 += "<\/optgroup>";
119
            [% END %]
120
            [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
121
                param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
122
            [% END %]
123
            param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
104
        [% END %]
124
        [% END %]
125
105
        param1 += "<\/select> <input id=\"cartsubmit\" type=\"submit\" class=\"submit\" value=\""+_("Save")+"\" />";
126
        param1 += "<\/select> <input id=\"cartsubmit\" type=\"submit\" class=\"submit\" value=\""+_("Save")+"\" />";
106
 $('#sortsubmit').hide();
127
 $('#sortsubmit').hide();
107
        $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
128
        $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-10 / +16 lines)
Lines 130-155 $(document).ready(function(){ Link Here
130
    [% IF ( intranetbookbag ) %]
130
    [% IF ( intranetbookbag ) %]
131
         param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
131
         param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
132
    [% END %]
132
    [% END %]
133
    [% IF ( virtualshelves ) %]
133
    [% IF Koha.Preference('virtualshelves') %]
134
        [% IF ( addbarshelves ) %]
134
        [% IF add_to_some_private_shelves.count %]
135
            param1 += "<optgroup label=\""+_("Your lists:")+"\">";
135
            param1 += "<optgroup label=\""+_("Your lists:")+"\">";
136
            [% FOREACH addbarshelvesloo IN addbarshelvesloop %]
136
            [% SET number_of_private_shelves = 0 %]
137
                [% IF ( shelfnumber != addbarshelvesloo.shelfnumber ) %]
137
            [% FOREACH s IN add_to_some_private_shelves %]
138
                    param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";
138
                [% IF shelfnumber != s.shelfnumber %]
139
                    param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
140
                    [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
141
                    [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
139
                [% END %]
142
                [% END %]
140
            [% END %]
143
            [% END %]
141
            param1 += "<\/optgroup>";
144
            param1 += "<\/optgroup>";
142
        [% END %]
145
        [% END %]
143
        [% IF ( addpubshelves ) %]
146
        [% IF add_to_some_public_shelves.count %]
144
            param1 += "<optgroup label=\""+_("Public lists:")+"\">";
147
            param1 += "<optgroup label=\""+_("Public lists:")+"\">";
145
            [% FOREACH addpubshelvesloo IN addpubshelvesloop %]
148
            [% SET number_of_public_shelves = 0 %]
146
                [% IF ( shelfnumber != addpubshelvesloo.shelfnumber ) %]
149
            [% FOREACH s IN add_to_some_public_shelves %]
147
                    param1 += "<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>";
150
                [% IF shelfnumber != s.shelfnumber %]
151
                    param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
152
                    [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
153
                    [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
148
                [% END %]
154
                [% END %]
149
            [% END %]
155
            [% END %]
150
            param1 += "<\/optgroup>";
156
            param1 += "<\/optgroup>";
151
        [% END %]
157
        [% END %]
152
        [% IF ( ( addbarshelvesloop && addbarshelvesloop.size > 9 ) || (addpubshelvesloop && addpubshelvesloop.size > 9 )) %]
158
        [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
153
            param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
159
            param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
154
        [% END %]
160
        [% END %]
155
        param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
161
        param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc (-23 / +33 lines)
Lines 37-68 Link Here
37
                            <li class="dropdown">
37
                            <li class="dropdown">
38
                                <a href="#" title="Show lists" class="dropdown-toggle" id="listsmenu" data-toggle="dropdown" role="button"><i class="icon-list icon-white"></i> <span class="listslabel">Lists</span> <b class="caret"></b></a>
38
                                <a href="#" title="Show lists" class="dropdown-toggle" id="listsmenu" data-toggle="dropdown" role="button"><i class="icon-list icon-white"></i> <span class="listslabel">Lists</span> <b class="caret"></b></a>
39
                                <ul aria-labelledby="listsmenu" role="menu" class="dropdown-menu">
39
                                <ul aria-labelledby="listsmenu" role="menu" class="dropdown-menu">
40
                                    [% IF ( pubshelves ) %]
40
                                [% IF some_public_shelves.count %]
41
                                            <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=2" tabindex="-1" role="menuitem"><strong>Public lists</strong></a></li>
41
                                    <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=2" tabindex="-1" role="menuitem"><strong>Public lists</strong></a></li>
42
                                        [% FOREACH pubshelvesloo IN pubshelvesloop %]
42
                                    [% SET number_of_public_shelves = 0 %]
43
                                            <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% pubshelvesloo.shelfnumber %]&amp;sortfield=[% pubshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% pubshelvesloo.shelfname |html %]</a></li>
43
                                    [% FOREACH s IN some_public_shelves %]
44
                                        [% END %]
44
                                        <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]&amp;sortfield=[% s.sortfield %]" tabindex="-1" role="menuitem">[% s.shelfname |html %]</a></li>
45
                                            <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=2" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li>
45
                                        [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
46
                                    [% ELSE %]
46
                                        [% IF number_of_public_shelves >= 10 %][% LAST %][% END %]
47
                                        <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No public lists</a></li>
48
                                    [% END %]
47
                                    [% END %]
49
                                    <li class="divider" role="presentation"></li>
48
                                    [% IF some_public_shelves > 10 %]
50
                                    [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
49
                                        <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=2" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li>
51
                                        <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1" tabindex="-1" role="menuitem"><strong>Your lists</strong></a></li>
50
                                    [% END %]
52
                                        [% IF ( loggedinusername ) %]
51
                                [% ELSE %]
53
                                            [% IF ( barshelves ) %]
52
                                    <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No public lists</a></li>
54
                                                [% FOREACH barshelvesloo IN barshelvesloop %]
53
                                [% END %]
55
                                                    <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% barshelvesloo.shelfnumber %]&amp;sortfield=[% barshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% barshelvesloo.shelfname |html %]</a></li>
54
                                <li class="divider" role="presentation"></li>
56
                                                [% END %]
55
                                [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
57
                                                <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1" tabindex="-1" role="menuitem" class="listmenulink">View all</a></li>
56
                                    <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1" tabindex="-1" role="menuitem"><strong>Your lists</strong></a></li>
58
                                            [% ELSE %]
57
                                    [% IF loggedinusername %]
59
                                                <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No private lists</a></li>
58
                                        [% IF some_private_shelves.count %]
60
                                                <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1" tabindex="-1" role="menuitem" class="listmenulink">New list</a></li>
59
                                            [% SET number_of_private_shelves = 0 %]
60
                                            [% FOREACH s IN some_private_shelves %]
61
                                                <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]&amp;sortfield=[% s.sortfield %]" tabindex="-1" role="menuitem">[% s.shelfname |html %]</a></li>
62
                                                [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
63
                                                [% IF number_of_private_shelves >= 10 %][% LAST %][% END %]
64
                                            [% END %]
65
                                            [% IF some_private_shelves > 10 %]
66
                                                <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li>
61
                                            [% END %]
67
                                            [% END %]
62
                                        [% ELSE %]
68
                                        [% ELSE %]
63
                                            <li role="presentation"><a href="/cgi-bin/koha/opac-user.pl" tabindex="-1" class="menu-inactive loginModal-trigger" role="menuitem">Log in to create your own lists</a></li>
69
                                            <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No private lists</a></li>
64
                                        [% END # / IF loggedinusername %]
70
                                            <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1" tabindex="-1" role="menuitem" class="listmenulink">New list</a></li>
65
                                    [% END # / IF opacuserlogin %]
71
                                        [% END %]
72
                                    [% ELSE %]
73
                                        <li role="presentation"><a href="/cgi-bin/koha/opac-user.pl" tabindex="-1" class="menu-inactive loginModal-trigger" role="menuitem">Log in to create your own lists</a></li>
74
                                    [% END # / IF loggedinusername %]
75
                                [% END # / IF opacuserlogin %]
66
                                </ul> <!-- / .dropdown-menu -->
76
                                </ul> <!-- / .dropdown-menu -->
67
                            </li> <!-- / .dropdown -->
77
                            </li> <!-- / .dropdown -->
68
                        [% END # / IF virtualshelves %]
78
                        [% END # / IF virtualshelves %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (-27 / +33 lines)
Lines 743-779 $(document).ready(function(){ Link Here
743
    param1 += "<span id=\"selections\">"+_("Select titles to: ")+"</span>";
743
    param1 += "<span id=\"selections\">"+_("Select titles to: ")+"</span>";
744
    [% END %]
744
    [% END %]
745
745
746
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
746
[% IF Koha.Preference( 'opacbookbag' ) == 1 OR Koha.Preference('virtualshelves') %]
747
    [% IF Koha.Preference( 'virtualshelves' ) == 1 %]
748
    param1 += "<select class=\"disabled\" name=\"addto\" id=\"addto\"><option>"+_("Add to...")+"</option>";
747
    param1 += "<select class=\"disabled\" name=\"addto\" id=\"addto\"><option>"+_("Add to...")+"</option>";
749
    [% IF Koha.Preference( 'opacbookbag' ) == 1 %]    param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
748
750
    [% END %][% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %][% IF ( addbarshelves ) %]
749
    [% IF Koha.Preference( 'opacbookbag' ) == 1 %]
751
    param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %]
750
        param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
752
    param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %]
753
    param1 += "<\/optgroup>";[% END %]
754
    [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %];
755
    param1 += "<\/optgroup>";[% END %]
756
    [% IF (( addbarshelvesloop && addbarshelvesloop.size>9) || (addpubshelvesloop && addpubshelvesloop.size>9 )) %]
757
        param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
758
    [% END %]
759
    param1 += "<option value=\"newlist\">[ "+_("New list")+" ]<\/option>";
760
    [% END %]
751
    [% END %]
752
    [% IF Koha.Preference('virtualshelves') %]
753
        [% IF loggedinusername AND add_to_some_private_shelves.count %]
754
            param1 += "<optgroup label=\""+_("Your lists:")+"\">";
755
            [% SET number_of_private_shelves = 0 %]
756
            [% FOREACH s IN add_to_some_private_shelves %]
757
                [% IF shelfnumber != s.shelfnumber %]
758
                    param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
759
                    [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
760
                    [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
761
                [% END %]
762
            [% END %]
763
            param1 += "<\/optgroup>";
764
        [% END %]
765
        [% IF add_to_some_public_shelves.count %]
766
            param1 += "<optgroup label=\""+_("Public lists:")+"\">";
767
            [% SET number_of_public_shelves = 0 %]
768
            [% FOREACH s IN add_to_some_public_shelves %]
769
                [% IF shelfnumber != s.shelfnumber %]
770
                    param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>";
771
                    [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
772
                    [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
773
                [% END %]
774
            [% END %]
775
            param1 += "<\/optgroup>";
776
        [% END %]
777
        [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
778
            param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
779
        [% END %]
780
        param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
761
    [% END %]
781
    [% END %]
762
    param1 += "<\/select> <input type=\"submit\" class=\"btn btn-small\" value=\""+_("Save")+"\" />";
782
    param1 += "<\/select> <input type=\"submit\" class=\"btn btn-small\" value=\""+_("Save")+"\" />";
763
    [% ELSE %]
764
        param1 += "<a id=\"addto\" class=\"addtocart\" href=\"#\">" + _("Add to cart") + "<\/a>";
765
    [% END %]
766
[% ELSE %]
767
        param1 += "<select name=\"addto\" id=\"addto\"><option value=\"\">"+_("Add to list: ")+"<\/option>";
768
[% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %][% IF ( addbarshelves ) %]
769
    param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %]
770
    param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %]
771
    param1 += "<\/optgroup>";[% END %]
772
    [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %][% END %]
773
    param1 +="<\/optgroup><option value=\"newlist\">[ "+_("New list")+" ]<\/option>"
774
    [% END %]
775
    [% END %]
776
    param1 += "<\/select> <input type=\"submit\" class=\"btn btn-small disabled\" value=\""+_("Save")+"\" />";
777
[% END %]
783
[% END %]
778
784
779
    $('#sortsubmit').hide();
785
    $('#sortsubmit').hide();
(-)a/members/deletemem.pl (-2 / +1 lines)
Lines 30-36 use C4::Output; Link Here
30
use C4::Auth;
30
use C4::Auth;
31
use C4::Members;
31
use C4::Members;
32
use C4::Branch; # GetBranches
32
use C4::Branch; # GetBranches
33
use C4::VirtualShelves (); #no import
34
use Module::Load;
33
use Module::Load;
35
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
34
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
36
    load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
35
    load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
Lines 147-153 output_html_with_http_headers $input, $cookie, $template->output; Link Here
147
146
148
} else {
147
} else {
149
    MoveMemberToDeleted($member);
148
    MoveMemberToDeleted($member);
150
    C4::VirtualShelves::HandleDelBorrower($member);
149
    C4::Members::HandleDelBorrower($member);
151
    DelMember($member);
150
    DelMember($member);
152
    print $input->redirect("/cgi-bin/koha/members/members-home.pl");
151
    print $input->redirect("/cgi-bin/koha/members/members-home.pl");
153
}
152
}
(-)a/misc/cronjobs/delete_patrons.pl (-2 / +1 lines)
Lines 6-12 use Pod::Usage; Link Here
6
use Getopt::Long;
6
use Getopt::Long;
7
7
8
use C4::Members;
8
use C4::Members;
9
use C4::VirtualShelves;
10
use Koha::DateUtils;
9
use Koha::DateUtils;
11
use C4::Log;
10
use C4::Log;
12
11
Lines 82-88 for my $member (@$members) { Link Here
82
        next;
81
        next;
83
    }
82
    }
84
    eval {
83
    eval {
85
        C4::VirtualShelves::HandleDelBorrower( $borrowernumber )
84
        C4::Members::HandleDelBorrower( $borrowernumber )
86
          if $confirm;
85
          if $confirm;
87
    };
86
    };
88
    if ($@) {
87
    if ($@) {
(-)a/opac/opac-search.pl (-8 / +19 lines)
Lines 943-957 if ($query_desc || $limit_desc) { Link Here
943
}
943
}
944
944
945
# VI. BUILD THE TEMPLATE
945
# VI. BUILD THE TEMPLATE
946
# Build drop-down list for 'Add To:' menu...
946
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
947
my ($totalref, $pubshelves, $barshelves)=
947
    {
948
	C4::VirtualShelves::GetSomeShelfNames($borrowernumber,'COMBO',1);
948
        borrowernumber => $borrowernumber,
949
        add_allowed    => 1,
950
        category       => 1,
951
    }
952
);
953
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
954
    {
955
        borrowernumber => $borrowernumber,
956
        add_allowed    => 1,
957
        category       => 2,
958
    }
959
);
960
while(my$s = $some_public_shelves->next){warn $s->shelfnumber;};
961
949
$template->param(
962
$template->param(
950
	addbarshelves     => $totalref->{bartotal},
963
    add_to_some_private_shelves => $some_private_shelves,
951
	addbarshelvesloop => $barshelves,
964
    add_to_some_public_shelves  => $some_public_shelves,
952
	addpubshelves     => $totalref->{pubtotal},
965
);
953
	addpubshelvesloop => $pubshelves,
954
	);
955
966
956
my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
967
my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
957
968
(-)a/opac/opac-shelves.pl (-6 lines)
Lines 283-295 if ( $op eq 'view' ) { Link Here
283
                push @items, $this_item;
283
                push @items, $this_item;
284
            }
284
            }
285
285
286
            # Build drop-down list for 'Add To:' menu...
287
            my ( $totalref, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $loggedinuser, 'COMBO', 1 );
288
            $template->param(
286
            $template->param(
289
                addbarshelves      => $totalref->{bartotal},
290
                addbarshelvesloop  => $barshelves,
291
                addpubshelves      => $totalref->{pubtotal},
292
                addpubshelvesloop  => $pubshelves,
293
                can_manage_shelf   => $shelf->can_be_managed($loggedinuser),
287
                can_manage_shelf   => $shelf->can_be_managed($loggedinuser),
294
                can_delete_shelf   => $shelf->can_be_deleted($loggedinuser),
288
                can_delete_shelf   => $shelf->can_be_deleted($loggedinuser),
295
                can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser),
289
                can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser),
(-)a/tools/cleanborrowers.pl (-2 / +1 lines)
Lines 39-45 use C4::Auth; Link Here
39
use C4::Output;
39
use C4::Output;
40
use C4::Members;        # GetBorrowersWhoHavexxxBorrowed.
40
use C4::Members;        # GetBorrowersWhoHavexxxBorrowed.
41
use C4::Circulation;    # AnonymiseIssueHistory.
41
use C4::Circulation;    # AnonymiseIssueHistory.
42
use C4::VirtualShelves ();    #no import
43
use Koha::DateUtils qw( dt_from_string output_pref );
42
use Koha::DateUtils qw( dt_from_string output_pref );
44
use Date::Calc qw/Today Add_Delta_YM/;
43
use Date::Calc qw/Today Add_Delta_YM/;
45
44
Lines 124-130 elsif ( $step == 3 ) { Link Here
124
            $radio eq 'testrun' && last;
123
            $radio eq 'testrun' && last;
125
            my $borrowernumber = $membersToDelete->[$i]->{'borrowernumber'};
124
            my $borrowernumber = $membersToDelete->[$i]->{'borrowernumber'};
126
            $radio eq 'trash' && MoveMemberToDeleted( $borrowernumber );
125
            $radio eq 'trash' && MoveMemberToDeleted( $borrowernumber );
127
            C4::VirtualShelves::HandleDelBorrower( $borrowernumber );
126
            C4::Members::HandleDelBorrower( $borrowernumber );
128
            DelMember( $borrowernumber );
127
            DelMember( $borrowernumber );
129
        }
128
        }
130
        $template->param(
129
        $template->param(
(-)a/virtualshelves/shelves.pl (-8 / +18 lines)
Lines 194-200 if ( $op eq 'view' ) { Link Here
194
    $shelf = Koha::Virtualshelves->find($shelfnumber);
194
    $shelf = Koha::Virtualshelves->find($shelfnumber);
195
    if ( $shelf ) {
195
    if ( $shelf ) {
196
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
196
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
197
            my $sortfield = $query->param('sortfield') || $shelf->sortfield;    # Passed in sorting overrides default sorting
197
            my $sortfield = $query->param('sortfield') || $shelf->sortfield || 'title';    # Passed in sorting overrides default sorting
198
            my $direction = $query->param('direction') || 'asc';
198
            my $direction = $query->param('direction') || 'asc';
199
            my ( $rows, $page );
199
            my ( $rows, $page );
200
            unless ( $query->param('print') ) {
200
            unless ( $query->param('print') ) {
Lines 241-253 if ( $op eq 'view' ) { Link Here
241
                push @items, $this_item;
241
                push @items, $this_item;
242
            }
242
            }
243
243
244
            # Build drop-down list for 'Add To:' menu...
244
            my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
245
            my ( $totalref, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $loggedinuser, 'COMBO', 1 );
245
                {
246
                    borrowernumber => $loggedinuser,
247
                    add_allowed    => 1,
248
                    category       => 1,
249
                }
250
            );
251
            my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
252
                {
253
                    borrowernumber => $loggedinuser,
254
                    add_allowed    => 1,
255
                    category       => 2,
256
                }
257
            );
258
246
            $template->param(
259
            $template->param(
247
                addbarshelves      => $totalref->{bartotal},
260
                add_to_some_private_shelves => $some_private_shelves,
248
                addbarshelvesloop  => $barshelves,
261
                add_to_some_public_shelves  => $some_public_shelves,
249
                addpubshelves      => $totalref->{pubtotal},
250
                addpubshelvesloop  => $pubshelves,
251
                can_manage_shelf   => $shelf->can_be_managed($loggedinuser),
262
                can_manage_shelf   => $shelf->can_be_managed($loggedinuser),
252
                can_remove_shelf   => $shelf->can_be_deleted($loggedinuser),
263
                can_remove_shelf   => $shelf->can_be_deleted($loggedinuser),
253
                can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser),
264
                can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser),
254
- 

Return to bug 14544