|
Lines 42-48
BEGIN {
Link Here
|
| 42 |
@EXPORT = qw( |
42 |
@EXPORT = qw( |
| 43 |
&GetShelves &GetShelfContents |
43 |
&GetShelves &GetShelfContents |
| 44 |
&AddToShelf |
44 |
&AddToShelf |
| 45 |
&ModShelf |
|
|
| 46 |
&ShelfPossibleAction |
45 |
&ShelfPossibleAction |
| 47 |
&DelFromShelf |
46 |
&DelFromShelf |
| 48 |
&GetBibliosShelves |
47 |
&GetBibliosShelves |
|
Lines 307-367
sub AddToShelf {
Link Here
|
| 307 |
$sth->execute( $shelfnumber ); |
306 |
$sth->execute( $shelfnumber ); |
| 308 |
} |
307 |
} |
| 309 |
|
308 |
|
| 310 |
=head2 ModShelf |
|
|
| 311 |
|
| 312 |
my $result= ModShelf($shelfnumber, $hashref) |
| 313 |
|
| 314 |
Where $hashref->{column} = param |
| 315 |
|
| 316 |
Modify the value into virtualshelves table with values given |
| 317 |
from hashref, which each key of the hashref should be |
| 318 |
the name of a column of virtualshelves. |
| 319 |
Fields like shelfnumber or owner cannot be changed. |
| 320 |
|
| 321 |
Returns 1 if the action seemed to be successful. |
| 322 |
|
| 323 |
=cut |
| 324 |
|
| 325 |
sub ModShelf { |
| 326 |
my ($shelfnumber,$hashref) = @_; |
| 327 |
my $dbh = C4::Context->dbh; |
| 328 |
|
| 329 |
my $query= "SELECT * FROM virtualshelves WHERE shelfnumber=?"; |
| 330 |
my $sth = $dbh->prepare($query); |
| 331 |
$sth->execute($shelfnumber); |
| 332 |
my $oldrecord= $sth->fetchrow_hashref; |
| 333 |
return 0 unless $oldrecord; #not found? |
| 334 |
|
| 335 |
#initialize missing hash values to silence warnings |
| 336 |
foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) { |
| 337 |
$hashref->{$_}= undef unless exists $hashref->{$_}; |
| 338 |
} |
| 339 |
|
| 340 |
#if name or category changes, the name should be tested |
| 341 |
if($hashref->{shelfname} || $hashref->{category}) { |
| 342 |
unless(_CheckShelfName( |
| 343 |
$hashref->{shelfname}//$oldrecord->{shelfname}, |
| 344 |
$hashref->{category}//$oldrecord->{category}, |
| 345 |
$oldrecord->{owner}, |
| 346 |
$shelfnumber )) { |
| 347 |
return 0; #name check failed |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
#only the following fields from the hash may be changed |
| 352 |
$query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?"; |
| 353 |
$sth = $dbh->prepare($query); |
| 354 |
$sth->execute( |
| 355 |
$hashref->{shelfname}//$oldrecord->{shelfname}, |
| 356 |
$hashref->{category}//$oldrecord->{category}, |
| 357 |
$hashref->{sortfield}//$oldrecord->{sortfield}, |
| 358 |
$hashref->{allow_add}//$oldrecord->{allow_add}, |
| 359 |
$hashref->{allow_delete_own}//$oldrecord->{allow_delete_own}, |
| 360 |
$hashref->{allow_delete_other}//$oldrecord->{allow_delete_other}, |
| 361 |
$shelfnumber ); |
| 362 |
return $@? 0: 1; |
| 363 |
} |
| 364 |
|
| 365 |
=head2 ShelfPossibleAction |
309 |
=head2 ShelfPossibleAction |
| 366 |
|
310 |
|
| 367 |
ShelfPossibleAction($loggedinuser, $shelfnumber, $action); |
311 |
ShelfPossibleAction($loggedinuser, $shelfnumber, $action); |