</actions>
</permacrud>
</class>
+ <class id="sdil" controller="open-ils.cstore" oils_obj:fieldmapper="seekdestroy::ignore_list" oils_persist:tablename="seekdestroy.ignore_list" reporter:label="Seek and Destroy Ignore List">
+ <fields oils_persist:primary="id" oils_persist:sequence="seekdestroy.ignore_list_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id" />
+ <field reporter:label="Report ID" name="report" reporter:datatype="int"/>
+ <field reporter:label="Copy ID" name="target_copy" reporter:datatype="int"/>
+ </fields>
+ </class>
<!-- no pcrud access is granted for now, because it's assumed these
setting values will be applied and retrived via the API. -->
use OpenILS::WWW::EGCatLoader::Account;
use OpenILS::WWW::EGCatLoader::Browse;
use OpenILS::WWW::EGCatLoader::Library;
+use OpenILS::WWW::EGCatLoader::Tattler;
use OpenILS::WWW::EGCatLoader::Search;
use OpenILS::WWW::EGCatLoader::Record;
use OpenILS::WWW::EGCatLoader::Course;
return $self->load_myopac_prefs if $path =~ m|opac/myopac/prefs|;
return $self->load_myopac_reservations if $path =~ m|opac/myopac/reservations|;
+ return $self->update_tattle_list if $path =~ m|opac/tattler|;
+
return Apache2::Const::OK;
}
--- /dev/null
+package OpenILS::WWW::EGCatLoader;
+use strict; use warnings;
+use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
+use OpenSRF::Utils::JSON;
+use OpenSRF::Utils::Logger qw/$logger/;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+use OpenILS::Utils::Fieldmapper;
+use OpenILS::Application::AppUtils;
+
+my $U = 'OpenILS::Application::AppUtils';
+
+sub update_tattle_list {
+ my $self = shift;
+ my $ctx = $self->ctx;
+ my $cgi = $self->cgi;
+ my $usr = $ctx->{user};
+ my $permission = $usr && $self->{editor}->allowed('UPDATE_RECORD');
+ return Apache2::Const::FORBIDDEN unless $permission;
+ my $copy_id = $cgi->param('copyid');
+ my $report = $cgi->param('reportid');
+ if( $copy_id && $report ) {
+ my $already_exists = $self->{editor}->json_query({
+ select => { sdil => ['id'] },
+ from => 'sdil',
+ where => {
+ report => $report,
+ target_copy => $copy_id
+ }
+ });
+ if( @$already_exists[0] ) {
+ $logger->info("Seek and Destroy Ignore report: $report, copy: $copy_id already exists");
+ $ctx->{status} = 2;
+ return Apache2::Const::OK;
+ }
+ $self->{editor}->xact_begin;
+ my $rec = Fieldmapper::seekdestroy::ignore_list->new;
+ $logger->info("Adding copy to seekdestory ignore list for $report on copy $copy_id");
+ $rec->target_copy($copy_id);
+ $rec->report($report);
+ $self->{editor}->create_seekdestroy_ignore_list($rec);
+ $self->{editor}->xact_commit;
+ $ctx->{status} = 1;
+ }
+ else {
+ $logger->info("Failed seekdestory ignore list for $report on copy $copy_id");
+ $ctx->{status} = 0;
+ }
+
+ return Apache2::Const::OK;
+}
+
+1;
\ No newline at end of file