<<

NAME

C4::Members::Attributes - manage extend patron attributes

SYNOPSIS

  use C4::Members::Attributes;
  my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);

FUNCTIONS

GetBorrowerAttributes

  my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber[, $opac_only]);

Retrieve an arrayref of extended attributes associated with the patron specified by $borrowernumber. Each entry in the arrayref is a hashref containing the following keys:

code (attribute type code) description (attribute type description) value (attribute value) value_description (attribute value description (if associated with an authorised value)) password (password, if any, associated with attribute

If the $opac_only parameter is present and has a true value, only the attributes marked for OPAC display are returned.

GetAttributes

  my $attributes = C4::Members::Attributes::GetAttributes([$opac_only]);

Retrieve an arrayref of extended attribute codes

GetBorrowerAttributeValue

  my $value = C4::Members::Attributes::GetBorrowerAttributeValue($borrowernumber, $attribute_code);

Retrieve the value of an extended attribute $attribute_code associated with the patron specified by $borrowernumber.

SearchIdMatchingAttribute

  my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($filter);

CheckUniqueness

  my $ok = CheckUniqueness($code, $value[, $borrowernumber]);

Given an attribute type and value, verify if would violate a unique_id restriction if added to the patron. The optional $borrowernumber is the patron that the attribute value would be added to, if known.

Returns false if the $code is not valid or the value would violate the uniqueness constraint.

SetBorrowerAttributes

  SetBorrowerAttributes($borrowernumber, [ { code => 'CODE', value => 'value', password => 'password' }, ... ] );

Set patron attributes for the patron identified by $borrowernumber, replacing any that existed previously.

DeleteBorrowerAttributes

  DeleteBorrowerAttributes($borrowernumber);

Delete borrower attributes for the patron identified by $borrowernumber.

DeleteBorrowerAttribute

  DeleteBorrowerAttribute($borrowernumber, $attribute);

Delete a borrower attribute for the patron identified by $borrowernumber and the attribute code of $attribute

UpdateBorrowerAttribute

  UpdateBorrowerAttribute($borrowernumber, $attribute );

Update a borrower attribute $attribute for the patron identified by $borrowernumber,

extended_attributes_code_value_arrayref

   my $patron_attributes = "homeroom:1150605,grade:01,extradata:foobar";
   my $aref = extended_attributes_code_value_arrayref($patron_attributes);

Takes a comma-delimited CSV-style string argument and returns the kind of data structure that SetBorrowerAttributes wants, namely a reference to array of hashrefs like: [ { code => 'CODE', value => 'value' }, { code => 'CODE2', value => 'othervalue' } ... ]

Caches Text::CSV parser object for efficiency.

extended_attributes_merge

  my $old_attributes = extended_attributes_code_value_arrayref("homeroom:224,grade:04,deanslist:2007,deanslist:2008,somedata:xxx");
  my $new_attributes = extended_attributes_code_value_arrayref("homeroom:115,grade:05,deanslist:2009,extradata:foobar");
  my $merged = extended_attributes_merge($patron_attributes, $new_attributes, 1);

  # assuming deanslist is a repeatable code, value same as:
  # $merged = extended_attributes_code_value_arrayref("homeroom:115,grade:05,deanslist:2007,deanslist:2008,deanslist:2009,extradata:foobar,somedata:xxx");

Takes three arguments. The first two are references to array of hashrefs, each like: [ { code => 'CODE', value => 'value' }, { code => 'CODE2', value => 'othervalue' } ... ]

The third option specifies whether repeatable codes are clobbered or collected. True for non-clobber.

Returns one reference to (merged) array of hashref.

Caches results of C4::Members::AttributeTypes::GetAttributeTypes_hashref(1) for efficiency.

AUTHOR

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

Galen Charlton <galen.charlton@liblime.com>

<<