[open-ils-commits] r9079 -
trunk/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Mar 19 10:20:45 EDT 2008
Author: erickson
Date: 2008-03-19 09:46:25 -0400 (Wed, 19 Mar 2008)
New Revision: 9079
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
ported org-settings update code to cstoreEditor
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-03-19 13:45:46 UTC (rev 9078)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-03-19 13:46:25 UTC (rev 9079)
@@ -78,39 +78,42 @@
}
-
__PACKAGE__->register_method(
method => "set_ou_settings",
api_name => "open-ils.actor.org_unit.settings.update",
);
sub set_ou_settings {
- my( $self, $client, $user_session, $ouid, $settings ) = @_;
-
- my( $staff, $evt ) = $apputils->checkses( $user_session );
- return $evt if $evt;
- $evt = $apputils->check_perms( $staff->id, $ouid, 'UPDATE_ORG_SETTING' );
- return $evt if $evt;
+ my( $self, $client, $auth, $org_id, $settings ) = @_;
- my @params;
- for my $set (keys %$settings) {
+ my $e = new_editor(authtoken => $auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->allowed('UPDATE_ORG_SETTING', $org_id);
- my $json = OpenSRF::Utils::JSON->perl2JSON($$settings{$set});
- $logger->activity("updating org_unit.setting: $ouid : $set : $json");
+ for my $name (keys %$settings) {
+ my $val = $$settings{$name};
+ my $set = $e->search_actor_org_unit_setting({org_unit => $org_id, name => $name})->[0];
- push( @params,
- { org_unit => $ouid, name => $set },
- { value => $json } );
- }
+ if(defined $val) {
+ $val = OpenSRF::Utils::JSON->perl2JSON($val);
+ if($set) {
+ $set->value($val);
+ $e->update_actor_org_unit_setting($set) or return $e->die_event;
+ } else {
+ $set = Fieldmapper::actor::org_unit_setting->new;
+ $set->org_unit($org_id);
+ $set->name($name);
+ $set->value($val);
+ $e->create_actor_org_unit_setting($set) or return $e->die_event;
+ }
+ } elsif($set) {
+ $e->delete_actor_org_unit_setting($set) or return $e->die_event;
+ }
+ }
- my $ses = $U->start_db_session();
- my $stat = $ses->request(
- 'open-ils.storage.direct.actor.org_unit_setting.merge', @params )->gather(1);
- $U->commit_db_session($ses);
-
- return $stat;
+ $e->commit;
+ return 1;
}
-
my $fetch_user_settings;
my $fetch_ou_settings;
More information about the open-ils-commits
mailing list