Lines 59-65
code (attribute type code)
Link Here
|
59 |
description (attribute type description) |
59 |
description (attribute type description) |
60 |
value (attribute value) |
60 |
value (attribute value) |
61 |
value_description (attribute value description (if associated with an authorised value)) |
61 |
value_description (attribute value description (if associated with an authorised value)) |
62 |
password (password, if any, associated with attribute |
|
|
63 |
|
62 |
|
64 |
If the C<$opac_only> parameter is present and has a true value, only the attributes |
63 |
If the C<$opac_only> parameter is present and has a true value, only the attributes |
65 |
marked for OPAC display are returned. |
64 |
marked for OPAC display are returned. |
Lines 71-77
sub GetBorrowerAttributes {
Link Here
|
71 |
my $opac_only = @_ ? shift : 0; |
70 |
my $opac_only = @_ ? shift : 0; |
72 |
|
71 |
|
73 |
my $dbh = C4::Context->dbh(); |
72 |
my $dbh = C4::Context->dbh(); |
74 |
my $query = "SELECT code, description, attribute, lib, password, display_checkout, category_code, class |
73 |
my $query = "SELECT code, description, attribute, lib, display_checkout, category_code, class |
75 |
FROM borrower_attributes |
74 |
FROM borrower_attributes |
76 |
JOIN borrower_attribute_types USING (code) |
75 |
JOIN borrower_attribute_types USING (code) |
77 |
LEFT JOIN authorised_values ON (category = authorised_value_category AND attribute = authorised_value) |
76 |
LEFT JOIN authorised_values ON (category = authorised_value_category AND attribute = authorised_value) |
Lines 87-93
sub GetBorrowerAttributes {
Link Here
|
87 |
description => $row->{'description'}, |
86 |
description => $row->{'description'}, |
88 |
value => $row->{'attribute'}, |
87 |
value => $row->{'attribute'}, |
89 |
value_description => $row->{'lib'}, |
88 |
value_description => $row->{'lib'}, |
90 |
password => $row->{'password'}, |
|
|
91 |
display_checkout => $row->{'display_checkout'}, |
89 |
display_checkout => $row->{'display_checkout'}, |
92 |
category_code => $row->{'category_code'}, |
90 |
category_code => $row->{'category_code'}, |
93 |
class => $row->{'class'}, |
91 |
class => $row->{'class'}, |
Lines 205-211
sub CheckUniqueness {
Link Here
|
205 |
|
203 |
|
206 |
=head2 SetBorrowerAttributes |
204 |
=head2 SetBorrowerAttributes |
207 |
|
205 |
|
208 |
SetBorrowerAttributes($borrowernumber, [ { code => 'CODE', value => 'value', password => 'password' }, ... ] ); |
206 |
SetBorrowerAttributes($borrowernumber, [ { code => 'CODE', value => 'value' }, ... ] ); |
209 |
|
207 |
|
210 |
Set patron attributes for the patron identified by C<$borrowernumber>, |
208 |
Set patron attributes for the patron identified by C<$borrowernumber>, |
211 |
replacing any that existed previously. |
209 |
replacing any that existed previously. |
Lines 221-231
sub SetBorrowerAttributes {
Link Here
|
221 |
|
219 |
|
222 |
DeleteBorrowerAttributes( $borrowernumber, $no_branch_limit ); |
220 |
DeleteBorrowerAttributes( $borrowernumber, $no_branch_limit ); |
223 |
|
221 |
|
224 |
my $sth = $dbh->prepare("INSERT INTO borrower_attributes (borrowernumber, code, attribute, password) |
222 |
my $sth = $dbh->prepare("INSERT INTO borrower_attributes (borrowernumber, code, attribute) |
225 |
VALUES (?, ?, ?, ?)"); |
223 |
VALUES (?, ?, ?)"); |
226 |
foreach my $attr (@$attr_list) { |
224 |
foreach my $attr (@$attr_list) { |
227 |
$attr->{password} = undef unless exists $attr->{password}; |
225 |
$sth->execute($borrowernumber, $attr->{code}, $attr->{value}); |
228 |
$sth->execute($borrowernumber, $attr->{code}, $attr->{value}, $attr->{password}); |
|
|
229 |
if ($sth->err) { |
226 |
if ($sth->err) { |
230 |
warn sprintf('Database returned the following error: %s', $sth->errstr); |
227 |
warn sprintf('Database returned the following error: %s', $sth->errstr); |
231 |
return; # bail immediately on errors |
228 |
return; # bail immediately on errors |
Lines 301-310
sub UpdateBorrowerAttribute {
Link Here
|
301 |
my $dbh = C4::Context->dbh; |
298 |
my $dbh = C4::Context->dbh; |
302 |
my $query = "INSERT INTO borrower_attributes SET attribute = ?, code = ?, borrowernumber = ?"; |
299 |
my $query = "INSERT INTO borrower_attributes SET attribute = ?, code = ?, borrowernumber = ?"; |
303 |
my @params = ( $attribute->{attribute}, $attribute->{code}, $borrowernumber ); |
300 |
my @params = ( $attribute->{attribute}, $attribute->{code}, $borrowernumber ); |
304 |
if ( defined $attribute->{password} ) { |
|
|
305 |
$query .= ", password = ?"; |
306 |
push @params, $attribute->{password}; |
307 |
} |
308 |
my $sth = $dbh->prepare( $query ); |
301 |
my $sth = $dbh->prepare( $query ); |
309 |
|
302 |
|
310 |
$sth->execute( @params ); |
303 |
$sth->execute( @params ); |