<<

NAME

C4::VirtualShelves - Functions for manipulating Koha virtual shelves

SYNOPSIS

  use C4::VirtualShelves;

DESCRIPTION

This module provides functions for manipulating virtual shelves, including creating and deleting virtual shelves, and adding and removing bibs to and from virtual shelves.

FUNCTIONS

GetShelves

  ($shelflist, $totshelves) = &GetShelves($category, $row_count, $offset, $owner);
  ($shelfnumber, $shelfhash) = each %{$shelflist};

Returns the number of shelves specified by $row_count and $offset as well as the total number of shelves that meet the $owner and $category criteria. $category, $row_count, and $offset are required. $owner must be supplied when $category == 1. When $category is 2, supply undef as argument for $owner.

This function is used by shelfpage in VirtualShelves/Page.pm when listing all shelves for lists management in opac or staff client. Order is by shelfname.

$shelflistis a reference-to-hash. The keys are the virtualshelves numbers ($shelfnumber, above), and the values ($shelfhash, above) are themselves references-to-hash, with the following keys:

$shelfhash->{shelfname}

A string. The name of the shelf.

$shelfhash->{count}

The number of virtuals on that virtualshelves.

GetAllShelves

    $shelflist = GetAllShelves($category, $owner)

This function returns a reference to an array of hashrefs containing all shelves sorted by the shelf name.

This function is intended to return a dataset reflecting all the shelves for the submitted parameters.

GetSomeShelfNames

Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header.

GetShelf

  (shelfnumber,shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other) = &GetShelf($shelfnumber);

Returns the above-mentioned fields for passed virtual shelf number.

GetShelfContents

  $biblist = &GetShelfContents($shelfnumber);

Looks up information about the contents of virtual virtualshelves number $shelfnumber. Sorted by a field in the biblio table. copyrightdate gives a desc sort.

Returns a reference-to-array, whose elements are references-to-hash, as returned by C4::Biblio::GetBiblioFromItemNumber.

Note: the notforloan status comes from the itemtype, and where it equals 0 it does not ensure that related items.notforloan status is likewise 0. The caller has to check any items on their own, possibly with CanBookBeIssued from C4::Circulation.

AddShelf

  $shelfnumber = &AddShelf($hashref, $owner);

Creates a new virtual shelf. Params passed in a hash like ModShelf.

Returns a code to know what's happen. * -1 : if this virtualshelves already exists. * $shelfnumber : if success.

AddToShelf

  &AddToShelf($biblionumber, $shelfnumber, $borrower);

Adds bib number $biblionumber to virtual virtualshelves number $shelfnumber, unless that bib is already on that shelf.

ModShelf

my $result= ModShelf($shelfnumber, $hashref)

Where $hashref->{column} = param

Modify the value into virtualshelves table with values given from hashref, which each key of the hashref should be the name of a column of virtualshelves. Fields like shelfnumber or owner cannot be changed.

Returns 1 if the action seemed to be successful.

ShelfPossibleAction

ShelfPossibleAction($loggedinuser, $shelfnumber, $action);

$loggedinuser,$shelfnumber,$action

$action can be "view", "add", "delete", "manage", "new_public", "new_private". New additional actions are: invite, acceptshare. Note that add/delete here refers to adding/deleting entries from the list. Deleting the list itself falls under manage. new_public and new_private refers to creating a new public or private list. The distinction between deleting your own entries from the list or entries from others is made in DelFromShelf.

Returns 1 if the user can do the $action in the $shelfnumber shelf. Returns 0 otherwise. For the actions invite and acceptshare a second errorcode is returned if the result is false. See opac-shareshelf.pl

DelFromShelf

    $result= &DelFromShelf( $bibref, $shelfnumber, $user);

Removes biblionumbers in passed arrayref from shelf $shelfnumber. If the bib wasn't on that virtualshelves to begin with, nothing happens.

Returns 0 if no items have been deleted.

DelShelf

  $Number = DelShelf($shelfnumber);

This function deletes the shelf number, and all of it's content. Authorization to do so MUST have been checked before calling, while using ShelfPossibleAction with manage parameter.

GetBibliosShelves

This finds all the public lists that this bib record is in.

ShelvesMax

    $howmany= ShelvesMax($context);

Tells how much shelves are shown in which context. POPUP refers to addbybiblionumber popup, MGRPAGE is managing page (in opac or staff), COMBO refers to the Add to-combo of search results. MASTHEAD is the main Koha toolbar with Lists button.

HandleDelBorrower

     HandleDelBorrower($borrower);

When a member is deleted (DelMember in Members.pm), you should call me first. This routine deletes/moves lists and entries for the deleted member/borrower. Lists owned by the borrower are deleted, but entries from the borrower to other lists are kept.

AddShare

     AddShare($shelfnumber, $key);

Adds a share request to the virtualshelves table. Authorization must have been checked, and a key must be supplied. See script opac-shareshelf.pl for an example. This request is not yet confirmed. So it has no borrowernumber, it does have an expiry date.

AcceptShare

     my $result= AcceptShare($shelfnumber, $key, $borrowernumber);

Checks acceptation of a share request. Key must be found for this shelf. Invitation must not have expired. Returns true when accepted, false otherwise.

IsSharedList

     my $bool= IsSharedList( $shelfnumber );

IsSharedList checks if a (private) list has shares. Note that such a check would not be useful for public lists. A public list has no shares, but is visible for anyone by nature.. Used to determine the list type in the display of Your lists (all private). Returns boolean value.

RemoveShare

     RemoveShare( $user, $shelfnumber );

RemoveShare removes a share for specific shelf and borrower. Returns true if a record could be deleted.

AUTHOR

Koha Development Team <http://koha-community.org/>

SEE ALSO

C4::Circulation::Circ2(3)

<<