Bug 19343: [16.11.X] Remove private lists with edit permission from search results
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tue, 3 Oct 2017 14:01:15 +0000 (16:01 +0200)
committerMason James <mtj@kohaaloha.com>
Tue, 24 Oct 2017 04:35:20 +0000 (17:35 +1300)
If the list is not shared, it should not be listed. We only need to remove
the allow_add line.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Conflicts:
Koha/Virtualshelves.pm

Koha/Virtualshelves.pm

index 75ccfa8..2469167 100644 (file)
@@ -119,6 +119,44 @@ sub get_some_shelves {
     );
 }
 
+sub get_shelves_containing_record {
+    my ( $self, $params ) = @_;
+    my $borrowernumber = $params->{borrowernumber};
+    my $biblionumber   = $params->{biblionumber};
+
+    my @conditions = ( 'virtualshelfcontents.biblionumber' => $biblionumber );
+    if ($borrowernumber) {
+        push @conditions,
+          {
+              -or => [
+                {
+                    category => 1,
+                    -or      => {
+                        'me.owner' => $borrowernumber,
+                        -or        => {
+                            'virtualshelfshares.borrowernumber' => $borrowernumber,
+                        },
+                    }
+                },
+                { category => 2 },
+            ]
+          };
+    } else {
+        push @conditions, { category => 2 };
+    }
+
+    return Koha::Virtualshelves->search(
+        {
+            -and => \@conditions
+        },
+        {
+            join     => [ 'virtualshelfcontents', 'virtualshelfshares' ],
+            group_by => 'shelfnumber',
+            order_by => { -asc => 'shelfname' },
+        }
+    );
+}
+
 sub _type {
     return 'Virtualshelve';
 }