[open-ils-commits] r14907 - in trunk/Open-ILS: examples src/perlmods/OpenILS/Application src/sql/Pg src/sql/Pg/upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Nov 13 13:23:07 EST 2009
Author: miker
Date: 2009-11-13 13:23:03 -0500 (Fri, 13 Nov 2009)
New Revision: 14907
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0083.schema.action_trigger.event_definition.opt_in.sql
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
Log:
adding support for user-opt-in when allowed on the event definition
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2009-11-13 18:20:09 UTC (rev 14906)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2009-11-13 18:23:03 UTC (rev 14907)
@@ -693,6 +693,8 @@
<field reporter:label="Template" name="template" reporter:datatype="text"/>
<field reporter:label="Name" name="name" reporter:datatype="text"/>
<field reporter:label="Granularity" name="granularity" reporter:datatype="text"/>
+ <field reporter:label="Opt-In User Field" name="usr_field" reporter:datatype="text"/>
+ <field reporter:label="Opt-In Setting Type" name="opt_in_setting" reporter:datatype="link"/>
<field reporter:label="Environmet Entries" name="env" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Parameters" name="params" oils_persist:virtual="true" reporter:datatype="link"/>
</fields>
@@ -705,6 +707,7 @@
<link field="cleanup_failure" reltype="has_a" key="module" map="" class="atclean"/>
<link field="env" reltype="has_many" key="event_def" map="" class="atenv"/>
<link field="params" reltype="has_many" key="event_def" map="" class="atevparam"/>
+ <link field="opt_in_setting" reltype="has_a" key="name" map="" class="cust"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
@@ -1106,11 +1109,12 @@
<class id="aus" controller="open-ils.cstore" oils_obj:fieldmapper="actor::user_setting" oils_persist:tablename="actor.usr_setting" reporter:label="User Setting">
<fields oils_persist:primary="id" oils_persist:sequence="actor.usr_setting_id_seq">
<field reporter:label="Setting ID" name="id" reporter:datatype="id" />
- <field reporter:label="Name" name="name" reporter:datatype="text"/>
+ <field reporter:label="Name" name="name" reporter:datatype="link"/>
<field reporter:label="User" name="usr" reporter:datatype="link"/>
<field reporter:label="Value" name="value" reporter:datatype="text"/>
</fields>
<links>
+ <link field="name" reltype="has_a" key="name" map="" class="cust"/>
<link field="usr" reltype="has_a" key="id" map="" class="au"/>
</links>
</class>
@@ -1736,6 +1740,26 @@
</links>
</class>
+ <class id="cust" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::usr_setting_type" oils_persist:tablename="config.usr_setting_type" reporter:label="User Setting Type">
+ <fields oils_persist:primary="name">
+ <field name="name" reporter:datatype="text"/>
+ <field name="label" reporter:datatype="text"/>
+ <field name="description" reporter:datatype="text"/>
+ <field name="datatype" reporter:datatype="text"/>
+ <field name="fm_class" reporter:datatype="text"/>
+ </fields>
+ <links>
+ <link field="name" reltype="has_many" key="name" map="" class="aus"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="ADMIN_USER_SETTING_TYPE" global_required="true"/>
+ <retrieve/>
+ <update permission="ADMIN_USER_SETTING_TYPE" global_required="true"/>
+ <delete permission="ADMIN_USER_SETTING_TYPE" global_required="true"/>
+ </actions>
+ </permacrud>
+ </class>
<class id="coust" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::org_unit_setting_type" oils_persist:tablename="config.org_unit_setting_type" reporter:label="Organizational Unit Setting Type">
<fields oils_persist:primary="name">
<field name="name" reporter:datatype="text"/>
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2009-11-13 18:20:09 UTC (rev 14906)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2009-11-13 18:23:03 UTC (rev 14907)
@@ -59,6 +59,21 @@
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 @@
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 @@
}
};
+ 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;
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-13 18:20:09 UTC (rev 14906)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-13 18:23:03 UTC (rev 14907)
@@ -51,7 +51,7 @@
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,
Modified: trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql 2009-11-13 18:20:09 UTC (rev 14906)
+++ trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql 2009-11-13 18:23:03 UTC (rev 14907)
@@ -115,6 +115,8 @@
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.
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0083.schema.action_trigger.event_definition.opt_in.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0083.schema.action_trigger.event_definition.opt_in.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0083.schema.action_trigger.event_definition.opt_in.sql 2009-11-13 18:23:03 UTC (rev 14907)
@@ -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;
+
More information about the open-ils-commits
mailing list