From: erickson Date: Mon, 15 Sep 2008 16:39:31 +0000 (+0000) Subject: general cleanup X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=25ba081800e440e01dcda50f57c4ab0cff322785;p=Evergreen.git general cleanup git-svn-id: svn://svn.open-ils.org/ILS/trunk@10591 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 7805652085..a443b1e5ba 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -1876,70 +1876,9 @@ sub checked_out { sub _checked_out { my( $iscount, $e, $userid ) = @_; - - my $meth = 'open-ils.storage.actor.user.checked_out'; $meth = "$meth.count" if $iscount; return $U->storagereq($meth, $userid); - -# XXX Old code - moved to storage -#------------------------------------------------------------------------------ -#------------------------------------------------------------------------------ - my $circs = $e->search_action_circulation( - { usr => $userid, checkin_time => undef }); - - my $parser = DateTime::Format::ISO8601->new; - - # split the circs up into overdue and not-overdue circs - my (@out,@overdue); - for my $c (@$circs) { - if( $c->due_date ) { - my $due_dt = $parser->parse_datetime( clense_ISO8601( $c->due_date ) ); - my $due = $due_dt->epoch; - if ($due < DateTime->today->epoch) { - push @overdue, $c; - } else { - push @out, $c; - } - } else { - push @out, $c; - } - } - - my( @open, @od, @lost, @cr, @lo ); - - while (my $c = shift(@out)) { - push( @open, $c->id ) if (!$c->stop_fines || $c->stop_fines eq 'MAXFINES' || $c->stop_fines eq 'RENEW'); - push( @lost, $c->id ) if $c->stop_fines eq 'LOST'; - push( @cr, $c->id ) if $c->stop_fines eq 'CLAIMSRETURNED'; - push( @lo, $c->id ) if $c->stop_fines eq 'LONGOVERDUE'; - } - - while (my $c = shift(@overdue)) { - push( @od, $c->id ) if (!$c->stop_fines || $c->stop_fines eq 'MAXFINES' || $c->stop_fines eq 'RENEW'); - push( @lost, $c->id ) if $c->stop_fines eq 'LOST'; - push( @cr, $c->id ) if $c->stop_fines eq 'CLAIMSRETURNED'; - push( @lo, $c->id ) if $c->stop_fines eq 'LONGOVERDUE'; - } - - if( $iscount ) { - return { - total => @open + @od + @lost + @cr + @lo, - out => scalar(@open), - overdue => scalar(@od), - lost => scalar(@lost), - claims_returned => scalar(@cr), - long_overdue => scalar(@lo) - }; - } - - return { - out => \@open, - overdue => \@od, - lost => \@lost, - claims_returned => \@cr, - long_overdue => \@lo - }; } @@ -2111,91 +2050,6 @@ __PACKAGE__->register_method( Returns a list of billable transaction ids for a user that has billings NOTES - - -=head old -sub _user_transaction_history { - my( $self, $client, $login_session, $user_id, $type ) = @_; - - my( $user_obj, $target, $evt ) = $apputils->checkses_requestor( - $login_session, $user_id, 'VIEW_USER_TRANSACTIONS' ); - return $evt if $evt; - - my $api = $self->api_name(); - my @xact; - my @charge; - my @balance; - - @xact = (xact_type => $type) if(defined($type)); - @balance = (balance_owed => { "!=" => 0}) if($api =~ /have_balance/); - @charge = (last_billing_ts => { "<>" => undef }) if $api =~ /have_charge/; - - $logger->debug("searching for transaction history: @xact : @balance, @charge"); - - my $trans = $apputils->simple_scalar_request( - "open-ils.cstore", - "open-ils.cstore.direct.money.billable_transaction_summary.search.atomic", - { usr => $user_id, @xact, @charge, @balance }, { order_by => { mbts => 'xact_start DESC' } }); - - return [ map { $_->id } @$trans ]; -} -=cut - -=head SEE APPUTILS.PM -sub _make_mbts { - my @xacts = @_; - - my @mbts; - for my $x (@xacts) { - my $s = new Fieldmapper::money::billable_transaction_summary; - $s->id( $x->id ); - $s->usr( $x->usr ); - $s->xact_start( $x->xact_start ); - $s->xact_finish( $x->xact_finish ); - - my $to = 0; - my $lb = undef; - for my $b (@{ $x->billings }) { - next if ($U->is_true($b->voided)); - $to += ($b->amount * 100); - $lb ||= $b->billing_ts; - if ($b->billing_ts ge $lb) { - $lb = $b->billing_ts; - $s->last_billing_note($b->note); - $s->last_billing_ts($b->billing_ts); - $s->last_billing_type($b->billing_type); - } - } - - $s->total_owed( sprintf('%0.2f', $to / 100 ) ); - - my $tp = 0; - my $lp = undef; - for my $p (@{ $x->payments }) { - next if ($U->is_true($p->voided)); - $tp += ($p->amount * 100); - $lp ||= $p->payment_ts; - if ($p->payment_ts ge $lp) { - $lp = $p->payment_ts; - $s->last_payment_note($p->note); - $s->last_payment_ts($p->payment_ts); - $s->last_payment_type($p->payment_type); - } - } - $s->total_paid( sprintf('%0.2f', $tp / 100 ) ); - - $s->balance_owed( sprintf('%0.2f', ($to - $tp) / 100) ); - - $s->xact_type( 'grocery' ) if ($x->grocery); - $s->xact_type( 'circulation' ) if ($x->circulation); - - push @mbts, $s; - } - - return @mbts; -} -=cut - sub user_transaction_history { my( $self, $conn, $auth, $userid, $type ) = @_; @@ -2335,35 +2189,6 @@ sub retrieve_groups_tree { } -# turns an org list into an org tree -=head old code -sub build_group_tree { - - my( $self, $grplist) = @_; - - return $grplist unless ( - ref($grplist) and @$grplist > 1 ); - - my @list = sort { $a->name cmp $b->name } @$grplist; - - my $root; - for my $grp (@list) { - - if ($grp and !defined($grp->parent)) { - $root = $grp; - next; - } - my ($parent) = grep { $_->id == $grp->parent} @list; - - $parent->children([]) unless defined($parent->children); - push( @{$parent->children}, $grp ); - } - - return $root; -} -=cut - - __PACKAGE__->register_method( method => "add_user_to_groups", api_name => "open-ils.actor.user.set_groups", diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm b/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm deleted file mode 100644 index 11c99ee91b..0000000000 --- a/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm +++ /dev/null @@ -1,212 +0,0 @@ -use strict; use warnings; -package OpenILS::Application::Auth; -use OpenILS::Application; -use base qw/OpenILS::Application/; -use OpenSRF::Utils::Cache; -use Digest::MD5 qw(md5_hex); -use OpenSRF::Utils::Logger qw(:level); -use OpenILS::Utils::Fieldmapper; -use OpenSRF::EX qw(:try); -use OpenILS::Application::AppUtils; -use OpenILS::Perm; -use OpenILS::Application::AppUtils; - -# memcache handle -my $cache_handle; -my $apputils = "OpenILS::Application::AppUtils"; - - -# ---------------------------------------------------------------------------- -# -# XXX This module is deprecated. Use the oils_auth.so C module. -# -# ---------------------------------------------------------------------------- - - - - - - - - - - - -# ------------------------------------------------------------- -# Methods -# ------------------------------------------------------------- -# ------------------------------------------------------------- - -__PACKAGE__->register_method( - method => "init_authenticate", - api_name => "open-ils.auth.authenticate.init", - argc => 1, #(username) - note => <register_method( - method => "complete_authenticate", - api_name => "open-ils.auth.authenticate.complete", - argc => 2, #( barcode, passwdhash ) - note => <register_method( - method => "retrieve_session", - api_name => "open-ils.auth.session.retrieve", - argc => 1, #( sessionid ) - note => <register_method( - method => "delete_session", - api_name => "open-ils.auth.session.delete", - argc => 1, #( sessionid ) - note => <new('global'); -} - - -# ------------------------------------------------------------- -# We build a random hash and put the hash along with the -# username into memcache (so that any backend may fulfill the -# auth request). -# ------------------------------------------------------------- -sub init_authenticate { - my( $self, $client, $username ) = @_; - my $seed = md5_hex( time() . $$ . rand() . $username ); - $cache_handle->put_cache( "_open-ils_seed_$username", $seed, 30 ); - warn "init happened with seed $seed\n"; - return $seed; -} - -# ------------------------------------------------------------- -# The temporary hash is removed from memcache. -# We retrieve the password from storage and verify -# their password hash against our re-hashed version of the -# password. If all goes well, we return the session id. -# Otherwise, we return "0" -# If type is set to 'opac', then this is an opac login, -# otherwise, it's a staff login -# ------------------------------------------------------------- -sub complete_authenticate { - my( $self, $client, $username, $passwdhash, $type ) = @_; - - my $name = "open-ils.cstore.direct.actor.user.search.atomic"; - - warn "Completing Authentication\n"; - - warn "Retrieving user from cstore..\n"; - my $user_list = OpenILS::Application::AppUtils->simple_scalar_request( - "open-ils.cstore", $name, { usrname => $username } ); - - unless(ref($user_list)) { - return { ilsevent => 1000 }; - } - - warn "We have the user from cstore with usrname $username\n"; - - my $user = $user_list->[0]; - - - if(!$user or !ref($user) ) { - return { ilsevent => 1000 }; - } - - my $password = $user->passwd(); - warn "user passwd is $password\n"; - - if(!$password) { - throw OpenSRF::EX::ERROR ("No password exists for $username", ERROR); - } - - warn "we have a password\n"; - - my $current_seed = $cache_handle->get_cache("_open-ils_seed_$username"); - $cache_handle->delete_cache( "_open-ils_seed_$username" ); - - warn "Removed tmp data from cache\n"; - - unless($current_seed) { - throw OpenSRF::EX::User - ("User must call open-ils.auth.init_authenticate first (or respond faster)"); - } - - my $hash = md5_hex($current_seed . $password); - - if( $hash eq $passwdhash ) { - # password is correct... do they have permission to login here? - - my $timeout = 28800; #staff login timeout - different for opac? - my $opactimeout = 604800; # 14 days - - if($type eq "opac") { - # 1 is the top level org unit (we should probably load the tree and get id from it) - warn "Checking user perms for OPAC login\n"; - if($apputils->check_user_perms($user->id(), 1, "OPAC_LOGIN")) { - return OpenILS::Perm->new("OPAC_LOGIN"); - } - - } else { - # 1 is the top level org unit (we should probably load the tree and get id from it) - warn "Checking user perms for Staff login\n"; - if($apputils->check_user_perms($user->id(), 1, "STAFF_LOGIN")) { - return OpenILS::Perm->new("STAFF_LOGIN"); - } - } - - my $session_id = md5_hex(time() . $$ . rand()); - $cache_handle->put_cache( $session_id, $user, $timeout ); - #return $session_id; - return { ilsevent => 0, authtoken => $session_id }; - - } else { - - warn "User password is incorrect...\n"; # send exception - return { ilsevent => 1000 }; - } -} - -sub retrieve_session { - my( $self, $client, $sessionid ) = @_; - my $user = $cache_handle->get_cache($sessionid); - if(!$user) { - warn "No User returned from retrieve_session $sessionid\n"; - } - if($user) {$user->clear_passwd();} - return $user; -} - -sub delete_session { - my( $self, $client, $sessionid ) = @_; - return $cache_handle->delete_cache($sessionid); -} - - -1; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 5ff9ca767a..aebcf90440 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -2096,48 +2096,6 @@ sub checkin_handle_backdate { -=head -# XXX Legacy version for Circ.pm support -sub _checkin_handle_backdate { - my( $class, $backdate, $circ, $requestor, $session, $closecirc ) = @_; - - my $bd = $backdate; - $bd =~ s/^(\d{4}-\d{2}-\d{2}).*/$1/og; - $bd = "${bd}T23:59:59"; - - my $bills = $session->request( - "open-ils.storage.direct.money.billing.search_where.atomic", - billing_ts => { '>=' => $bd }, - xact => $circ->id, - billing_type => OILS_BILLING_TYPE_OVERDUE_MATERIALS - )->gather(1); - - $logger->debug("backdate found ".scalar(@$bills)." bills to void"); - - if($bills) { - for my $bill (@$bills) { - unless( $U->is_true($bill->voided) ) { - $logger->debug("voiding bill ".$bill->id); - $bill->voided('t'); - $bill->void_time('now'); - $bill->voider($requestor->id); - my $n = $bill->note || ""; - $bill->note($n . "\nSystem: VOIDED FOR BACKDATE"); - my $s = $session->request( - "open-ils.storage.direct.money.billing.update", $bill)->gather(1); - return $U->DB_UPDATE_FAILED($bill) unless $s; - } - } - } - - return 100; -} -=cut - - - - - sub find_patron_from_copy { my $self = shift; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index feac958668..6ec2104ccf 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -762,30 +762,6 @@ __PACKAGE__->register_method ( @return ID of the new object on success, Event on error / ); -=head old -sub __create_hold_notify { - my( $self, $conn, $authtoken, $notification ) = @_; - my( $requestor, $evt ) = $U->checkses($authtoken); - return $evt if $evt; - my ($hold, $patron); - ($hold, $evt) = $U->fetch_hold($notification->hold); - return $evt if $evt; - ($patron, $evt) = $U->fetch_user($hold->usr); - return $evt if $evt; - - # XXX perm depth probably doesn't matter here -- should always be consortium level - $evt = $U->check_perms($requestor->id, $patron->home_ou, 'CREATE_HOLD_NOTIFICATION'); - return $evt if $evt; - - # Set the proper notifier - $notification->notify_staff($requestor->id); - my $id = $U->storagereq( - 'open-ils.storage.direct.action.hold_notification.create', $notification ); - return $U->DB_UPDATE_FAILED($notification) unless $id; - $logger->info("User ".$requestor->id." successfully created new hold notification $id"); - return $id; -} -=cut sub create_hold_notify { my( $self, $conn, $auth, $note ) = @_;