From: miker Date: Fri, 13 Nov 2009 18:23:03 +0000 (+0000) Subject: adding support for user-opt-in when allowed on the event definition X-Git-Tag: kcls-grey-screen-prod1~3013 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2471fd1c5901301ead7d83abf72cdcd5f0356b9e;p=evergreen%2Fequinox.git adding support for user-opt-in when allowed on the event definition git-svn-id: svn://svn.open-ils.org/ILS/trunk@14907 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 35a1ed8a8d..273f4da662 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -693,6 +693,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -705,6 +707,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -1106,11 +1109,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + + @@ -1736,6 +1740,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm index 99c7f3855c..994f01ea44 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm @@ -59,6 +59,21 @@ sub create_active_events_for_object { for my $def ( @$defs ) { + if ($def->usr_field && $def->opt_in_setting) { + my $ufield = $def->usr_field; + my $uid = $target->$ufield; + $uid = $uid->id if (ref $uid); # fleshed user object, unflesh it + + my $opt_in_setting = $editor->search_actor_usr_setting( + { usr => $uid, + name => $def->opt_in_setting, + value => 'true' + } + ); + + next unless (@$opt_in_setting); + } + my $date = DateTime->now; if ($hook_hash{$def->hook}->passive eq 'f') { @@ -128,6 +143,21 @@ sub create_event_for_object_and_def { for my $def ( @$defs ) { + if ($def->usr_field && $def->opt_in_setting) { + my $ufield = $def->usr_field; + my $uid = $target->$ufield; + $uid = $uid->id if (ref $uid); # fleshed user object, unflesh it + + my $opt_in_setting = $editor->search_actor_usr_setting( + { usr => $uid, + name => $def->opt_in_setting, + value => 'true' + } + ); + + next unless (@$opt_in_setting); + } + my $date = DateTime->now; if ($hook_hash{$def->hook}->passive eq 'f') { @@ -426,6 +456,19 @@ sub create_batch_events { } }; + if ($def->usr_field && $def->opt_in_setting) { + push @{ $filter->{'-and'} }, { + '-exists' => { + from => 'aus', + where => { + name => $def->id, + usr => { '=' => { '+' . $hook_hash{$def->hook}->core_type => $def->usr_field } }, + value=> 'true' + } + } + }; + } + $class =~ s/^Fieldmapper:://o; $class =~ s/::/_/go; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 870131ab01..2d6755228c 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0082'); -- miker +INSERT INTO config.upgrade_log (version) VALUES ('0083'); -- miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql b/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql index a225a51d01..37e2971a65 100644 --- a/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql +++ b/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql @@ -115,6 +115,8 @@ CREATE TABLE action_trigger.event_definition ( cleanup_failure TEXT REFERENCES action_trigger.cleanup (module) DEFERRABLE INITIALLY DEFERRED, delay INTERVAL NOT NULL DEFAULT '5 minutes', max_delay INTERVAL, + usr_field TEXT, + opt_in_setting TEXT REFERENCES config.usr_setting_type (name) DEFERRABLE INITIALLY DEFERRED, delay_field TEXT, -- for instance, xact_start on a circ hook ... look for fields on hook.core_type where datatype=timestamp? If not set, delay from now() group_field TEXT, -- field from this.hook.core_type to batch event targets together on, fed into reactor a group at a time. template TEXT, -- the TT block. will have an 'environment' hash (or array of hashes, grouped events) built up by validator and collector(s), which can be modified. diff --git a/Open-ILS/src/sql/Pg/upgrade/0083.schema.action_trigger.event_definition.opt_in.sql b/Open-ILS/src/sql/Pg/upgrade/0083.schema.action_trigger.event_definition.opt_in.sql new file mode 100644 index 0000000000..36cfd4110d --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0083.schema.action_trigger.event_definition.opt_in.sql @@ -0,0 +1,9 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0083'); + +ALTER TABLE action_trigger.event_definition ADD COLUMN usr_field TEXT; +ALTER TABLE action_trigger.event_definition ADD COLUMN opt_in_setting TEXT REFERENCES config.usr_setting_type (name) DEFERRABLE INITIALLY DEFERRED; + +COMMIT; +