[open-ils-commits] SPAM: r10591 - in
trunk/Open-ILS/src/perlmods/OpenILS/Application: . Circ
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Sep 15 12:39:33 EDT 2008
Author: erickson
Date: 2008-09-15 12:39:31 -0400 (Mon, 15 Sep 2008)
New Revision: 10591
Removed:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
general cleanup
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-09-14 00:32:29 UTC (rev 10590)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-09-15 16:39:31 UTC (rev 10591)
@@ -1876,70 +1876,9 @@
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, at 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 @@
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 @@
}
-# 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",
Deleted: trunk/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm 2008-09-14 00:32:29 UTC (rev 10590)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm 2008-09-15 16:39:31 UTC (rev 10591)
@@ -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 => <<TEXT,
-Generates a random seed and returns it. The client
-must then perform md5_hex( \$seed . \$password ) and use that
-as the passwordhash to open-ils.auth.authenticate.complete
-TEXT
-);
-
-__PACKAGE__->register_method(
- method => "complete_authenticate",
- api_name => "open-ils.auth.authenticate.complete",
- argc => 2, #( barcode, passwdhash )
- note => <<TEXT,
-Client provides the username and passwordhash (see
-open-ils.auth.authenticate.init). If their password hash is
-correct for the given username, a session id is returned,
-if not, "0" is returned
-TEXT
-);
-
-__PACKAGE__->register_method(
- method => "retrieve_session",
- api_name => "open-ils.auth.session.retrieve",
- argc => 1, #( sessionid )
- note => <<TEXT,
-Pass in a sessionid and this returns the username associated with it
-TEXT
-);
-
-__PACKAGE__->register_method(
- method => "delete_session",
- api_name => "open-ils.auth.session.delete",
- argc => 1, #( sessionid )
- note => <<TEXT,
-Pass in a sessionid and this delete it from the cache
-TEXT
-);
-
-
-# -------------------------------------------------------------
-# Implementation
-# -------------------------------------------------------------
-# -------------------------------------------------------------
-
-
-# -------------------------------------------------------------
-# connect to the memcache server
-# -------------------------------------------------------------
-sub child_init {
- $cache_handle = OpenSRF::Utils::Cache->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;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2008-09-14 00:32:29 UTC (rev 10590)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2008-09-15 16:39:31 UTC (rev 10591)
@@ -2096,49 +2096,7 @@
-=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;
my $circs = $self->editor->search_action_circulation(
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2008-09-14 00:32:29 UTC (rev 10590)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2008-09-15 16:39:31 UTC (rev 10591)
@@ -762,31 +762,7 @@
@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 ) = @_;
my $e = new_editor(authtoken=>$auth, xact=>1);
More information about the open-ils-commits
mailing list