User Setting Registration Defaults
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 2 Oct 2012 20:47:42 +0000 (16:47 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 12 Jul 2013 16:26:32 +0000 (12:26 -0400)
Add a new reg_default value for user setting types. On patron registration
the value (if any) is used as a default for the patron.

Only applicable to those settings editable via the patron editor.

Intended use cases:

1 - Hold Notification Type Default other than phone:email
2 - A/T user settings defaulting to "on" at registration

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.usr_setting_default.sql [new file with mode: 0644]
Open-ILS/web/js/ui/default/actor/user/register.js

index cbdd13b..6ea71d4 100644 (file)
@@ -3110,6 +3110,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="fm_class" reporter:label="Fielmapper Class" reporter:datatype="text"/>
                        <field name="grp" reporter:label="Settings Group" reporter:datatype="link"/>
                        <field name="opac_visible" reporter:label="OPAC/Patron Visible" reporter:datatype="bool"/>
                        <field name="fm_class" reporter:label="Fielmapper Class" reporter:datatype="text"/>
                        <field name="grp" reporter:label="Settings Group" reporter:datatype="link"/>
                        <field name="opac_visible" reporter:label="OPAC/Patron Visible" reporter:datatype="bool"/>
+            <field name="reg_default" reporter:label="Registration Default" reporter:datatype="text"/>
                </fields>
                <links>
                        <link field="name" reltype="has_many" key="name" map="" class="aus"/>
                </fields>
                <links>
                        <link field="name" reltype="has_many" key="name" map="" class="aus"/>
index 35c130b..2d44af9 100644 (file)
@@ -614,6 +614,7 @@ CREATE TABLE config.usr_setting_type (
     grp             TEXT    REFERENCES config.settings_group (name),
     datatype TEXT NOT NULL DEFAULT 'string',
     fm_class TEXT,
     grp             TEXT    REFERENCES config.settings_group (name),
     datatype TEXT NOT NULL DEFAULT 'string',
     fm_class TEXT,
+    reg_default TEXT,
 
     --
     -- define valid datatypes
 
     --
     -- define valid datatypes
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.usr_setting_default.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.usr_setting_default.sql
new file mode 100644 (file)
index 0000000..e55e1e2
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE config.usr_setting_type
+    ADD COLUMN reg_default TEXT;
index 58c2c70..e70d867 100644 (file)
@@ -672,6 +672,14 @@ function uEditFetchUserSettings(userId) {
         userSettings = fieldmapper.standardRequest(
             ['open-ils.actor', 'open-ils.actor.patron.settings.retrieve.authoritative'],
             {params : [openils.User.authtoken, userId, names]});
         userSettings = fieldmapper.standardRequest(
             ['open-ils.actor', 'open-ils.actor.patron.settings.retrieve.authoritative'],
             {params : [openils.User.authtoken, userId, names]});
+    } else {
+        // Defaults!
+        userSettingTypes.forEach(function(setting, index, array) {
+            if(setting.reg_default() != undefined) {
+                userSettings[setting.name()] = setting.reg_default();
+                userSettingsToUpdate[setting.name()] = setting.reg_default();
+            }
+        });
     }
 }
 
     }
 }