3 SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
5 INSERT into config.org_unit_setting_type
6 ( name, grp, label, description, datatype, fm_class ) VALUES
7 ( 'opac.email_record.allow_without_login', 'opac',
8 oils_i18n_gettext('opac.email_record.allow_without_login',
9 'Allow record emailing without login',
11 oils_i18n_gettext('opac.email_record.allow_without_login',
12 'Instead of forcing a patron to log in in order to email the details of a record, just challenge them with a simple catpcha.',
13 'coust', 'description'),
17 CREATE TABLE action_trigger.event_def_group (
18 id SERIAL PRIMARY KEY,
19 owner INT NOT NULL REFERENCES actor.org_unit (id)
20 ON DELETE RESTRICT ON UPDATE CASCADE
21 DEFERRABLE INITIALLY DEFERRED,
22 hook TEXT NOT NULL REFERENCES action_trigger.hook (key)
23 ON DELETE RESTRICT ON UPDATE CASCADE
24 DEFERRABLE INITIALLY DEFERRED,
25 active BOOL NOT NULL DEFAULT TRUE,
28 SELECT SETVAL('action_trigger.event_def_group_id_seq'::TEXT, 100, TRUE);
30 CREATE TABLE action_trigger.event_def_group_member (
31 id SERIAL PRIMARY KEY,
32 grp INT NOT NULL REFERENCES action_trigger.event_def_group (id)
33 ON DELETE CASCADE ON UPDATE CASCADE
34 DEFERRABLE INITIALLY DEFERRED,
35 event_def INT NOT NULL REFERENCES action_trigger.event_definition (id)
36 ON DELETE RESTRICT ON UPDATE CASCADE
37 DEFERRABLE INITIALLY DEFERRED,
38 sortable BOOL NOT NULL DEFAULT TRUE,
39 holdings BOOL NOT NULL DEFAULT FALSE,
40 external BOOL NOT NULL DEFAULT FALSE,
44 INSERT INTO action_trigger.event_def_group (id, owner, hook, name)
45 VALUES (1, 1, 'biblio.format.record_entry.print','Print Record(s)');
47 INSERT INTO action_trigger.event_def_group (id, owner, hook, name)
48 VALUES (2,1,'biblio.format.record_entry.email','Email Record(s)');
52 PERFORM * FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.email' AND owner = 1 AND active AND template =
55 [%- SET user = target.0.owner -%]
56 To: [%- params.recipient_email || user.email %]
57 From: [%- params.sender_email || default_sender %]
58 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
59 Subject: Bibliographic Records
60 Auto-Submitted: auto-generated
62 [% FOR cbreb IN target %]
63 [% FOR item IN cbreb.items;
64 bre_id = item.target_biblio_record_entry;
66 bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
68 FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
69 title = title _ part.textContent;
72 author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
73 item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
74 publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
75 pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
76 isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
77 issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
78 upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
81 [% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %]
82 [% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%]
83 [% IF issn %]ISSN: [% issn _ "\n" %][% END -%]
84 [% IF upc %]UPC: [% upc _ "\n" %] [% END -%]
87 Publication Info: [% publisher %] [% pubdate %]
88 Item Type: [% item_type %]
94 IF FOUND THEN -- update
96 INSERT INTO action_trigger.event_def_group_member (grp, name, event_def)
97 SELECT 2, 'Brief', id FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.email';
99 INSERT INTO action_trigger.event_def_group_member (grp, name, holdings, event_def)
100 SELECT 2, 'Full', TRUE, id FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.email';
102 UPDATE action_trigger.event_definition SET template = $$
104 [%- SET user = target.0.owner -%]
105 To: [%- params.recipient_email || user_data.0.email || user.email %]
106 From: [%- params.sender_email || default_sender %]
107 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
108 Subject: [%- user_data.0.subject || 'Bibliographic Records' %]
109 Auto-Submitted: auto-generated
111 [%- FOR cbreb IN target;
114 IF user_data.0.type == 'full';
115 flesh_list = flesh_list _ ',holdings_xml,acp';
116 IF params.holdings_limit;
117 flimit = 'acn=>' _ params.holdings_limit _ ',acp=>' _ params.holdings_limit;
120 flesh_list = flesh_list _ '}';
122 item_list = helpers.sort_bucket_unapi_bre(cbreb.items,{flesh => flesh_list, site => user_data.0.context_org, flesh_limit => flimit}, user_data.0.sort_by, user_data.0.sort_dir);
124 FOR item IN item_list -%]
126 [% loop.count %]/[% loop.size %]. Bib ID# [% item.id %]
127 [% IF item.isbn %]ISBN: [% item.isbn _ "\n" %][% END -%]
128 [% IF item.issn %]ISSN: [% item.issn _ "\n" %][% END -%]
129 [% IF item.upc %]UPC: [% item.upc _ "\n" %][% END -%]
130 Title: [% item.title %]
131 [% IF item.author %]Author: [% item.author _ "\n" %][% END -%]
132 Publication Info: [% item.publisher %] [% item.pubdate %]
133 Item Type: [% item.item_type %]
134 [% IF user_data.0.type == 'full' && item.holdings.size == 0 %]
135 * No items for this record at the selected location
137 [% FOR cp IN item.holdings -%]
138 * Library: [% cp.circ_lib %]
139 Location: [% cp.location %]
140 Call Number: [% cp.prefix _ ' ' _ cp.callnumber _ ' ' _ cp.suffix %]
141 [% IF cp.parts %] Parts: [% cp.parts _ "\n" %][% END -%]
142 Status: [% cp.status_label %]
143 Barcode: [% cp.barcode %]
148 $$ WHERE hook = 'biblio.format.record_entry.email' AND owner = 1 AND active;
150 ELSE -- insert full and add existing brief
152 INSERT INTO action_trigger.event_def_group_member (grp, name, event_def)
153 SELECT 2, 'Brief', id FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.email' AND active;
155 INSERT INTO action_trigger.event_definition (
171 'biblio.record_entry.email.full',
172 'biblio.format.record_entry.email',
175 'DeleteTempBiblioBucket',
176 'DeleteTempBiblioBucket',
182 [%- SET user = target.0.owner -%]
183 To: [%- params.recipient_email || user_data.0.email || user.email %]
184 From: [%- params.sender_email || default_sender %]
185 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
186 Subject: [%- user_data.0.subject || 'Bibliographic Records' %]
187 Auto-Submitted: auto-generated
189 [%- FOR cbreb IN target;
192 IF user_data.0.type == 'full';
193 flesh_list = flesh_list _ ',holdings_xml,acp';
194 IF params.holdings_limit;
195 flimit = 'acn=>' _ params.holdings_limit _ ',acp=>' _ params.holdings_limit;
198 flesh_list = flesh_list _ '}';
200 item_list = helpers.sort_bucket_unapi_bre(cbreb.items,{flesh => flesh_list, site => user_data.0.context_org, flesh_limit => flimit}, user_data.0.sort_by, user_data.0.sort_dir);
202 FOR item IN item_list -%]
204 [% loop.count %]/[% loop.size %]. Bib ID# [% item.id %]
205 [% IF item.isbn %]ISBN: [% item.isbn _ "\n" %][% END -%]
206 [% IF item.issn %]ISSN: [% item.issn _ "\n" %][% END -%]
207 [% IF item.upc %]UPC: [% item.upc _ "\n" %][% END -%]
208 Title: [% item.title %]
209 [% IF item.author %]Author: [% item.author _ "\n" %][% END -%]
210 Publication Info: [% item.publisher %] [% item.pubdate %]
211 Item Type: [% item.item_type %]
212 [% IF user_data.0.type == 'full' && item.holdings.size == 0 %]
213 * No items for this record at the selected location
215 [% FOR cp IN item.holdings -%]
216 * Library: [% cp.circ_lib %]
217 Location: [% cp.location %]
218 Call Number: [% cp.prefix _ ' ' _ cp.callnumber _ ' ' _ cp.suffix %]
219 [% IF cp.parts %] Parts: [% cp.parts _ "\n" %][% END -%]
220 Status: [% cp.status_label %]
221 Barcode: [% cp.barcode %]
226 $$ FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.email' AND active;
228 INSERT INTO action_trigger.event_def_group_member (grp, name, holdings, event_def)
229 SELECT 2, 'Full', TRUE, id FROM action_trigger.event_definition WHERE name = 'biblio.record_entry.email.full' and active;
237 PERFORM * FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.print' AND owner = 1 AND active AND template =
240 <style> li { padding: 8px; margin 5px; }</style>
242 [% FOR cbreb IN target %]
243 [% FOR item IN cbreb.items;
244 bre_id = item.target_biblio_record_entry;
246 bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
248 FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
249 title = title _ part.textContent;
252 author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
253 item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
254 publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
255 pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
256 isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
260 Bib ID# [% bre_id %] ISBN: [% isbn %]<br />
261 Title: [% title %]<br />
262 Author: [% author %]<br />
263 Publication Info: [% publisher %] [% pubdate %]<br/>
264 Item Type: [% item_type %]
272 IF FOUND THEN -- update
274 INSERT INTO action_trigger.event_def_group_member (grp, name, event_def)
275 SELECT 1, 'Brief', id FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.print';
277 INSERT INTO action_trigger.event_def_group_member (grp, name, holdings, event_def)
278 SELECT 1, 'Full', TRUE, id FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.print';
280 UPDATE action_trigger.event_definition SET template = $$
282 <style> li { padding: 8px; margin 5px; }</style>
284 [% FOR cbreb IN target;
287 IF user_data.0.type == 'full';
288 flesh_list = flesh_list _ ',holdings_xml,acp';
289 IF params.holdings_limit;
290 flimit = 'acn=>' _ params.holdings_limit _ ',acp=>' _ params.holdings_limit;
293 flesh_list = flesh_list _ '}';
295 item_list = helpers.sort_bucket_unapi_bre(cbreb.items,{flesh => flesh_list, site => user_data.0.context_org, flesh_limit => flimit}, user_data.0.sort_by, user_data.0.sort_dir);
296 FOR item IN item_list %]
298 Bib ID# [% item.id %]<br />
299 [% IF item.isbn %]ISBN: [% item.isbn %]<br />[% END %]
300 [% IF item.issn %]ISSN: [% item.issn %]<br />[% END %]
301 [% IF item.upc %]UPC: [% item.upc %]<br />[% END %]
302 Title: [% item.title %]<br />
303 [% IF item.author %] Author: [% item.author %]<br />[% END -%]
304 Publication Info: [% item.publisher %] [% item.pubdate %]<br/>
305 Item Type: [% item.item_type %]
307 [% IF user_data.0.type == 'full' && item.holdings.size == 0 %]
308 <li>No items for this record at the selected location</li>
310 [% FOR cp IN item.holdings -%]
312 Library: [% cp.circ_lib %]<br/>
313 Location: [% cp.location %]<br/>
314 Call Number: [% cp.prefix _ ' ' _ cp.callnumber _ ' ' _ cp.suffix %]<br/>
315 [% IF cp.parts %]Parts: [% cp.parts %]<br/>[% END %]
316 Status: [% cp.status_label %]<br/>
317 Barcode: [% cp.barcode %]
326 $$ WHERE hook = 'biblio.format.record_entry.print' AND owner = 1 AND active;
328 ELSE -- insert full and add brief
330 INSERT INTO action_trigger.event_def_group_member (grp, name, event_def)
331 SELECT 1, 'Brief', id FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.print' AND active;
333 INSERT INTO action_trigger.event_definition (
349 'biblio.record_entry.print.full',
350 'biblio.format.record_entry.print',
353 'DeleteTempBiblioBucket',
354 'DeleteTempBiblioBucket',
360 <style> li { padding: 8px; margin 5px; }</style>
362 [% FOR cbreb IN target;
365 IF user_data.0.type == 'full';
366 flesh_list = flesh_list _ ',holdings_xml,acp';
367 IF params.holdings_limit;
368 flimit = 'acn=>' _ params.holdings_limit _ ',acp=>' _ params.holdings_limit;
371 flesh_list = flesh_list _ '}';
373 item_list = helpers.sort_bucket_unapi_bre(cbreb.items,{flesh => flesh_list, site => user_data.0.context_org, flesh_limit => flimit}, user_data.0.sort_by, user_data.0.sort_dir);
374 FOR item IN item_list %]
376 Bib ID# [% item.id %]<br />
377 [% IF item.isbn %]ISBN: [% item.isbn %]<br />[% END %]
378 [% IF item.issn %]ISSN: [% item.issn %]<br />[% END %]
379 [% IF item.upc %]UPC: [% item.upc %]<br />[% END %]
380 Title: [% item.title %]<br />
381 [% IF item.author %] Author: [% item.author %]<br />[% END -%]
382 Publication Info: [% item.publisher %] [% item.pubdate %]<br/>
383 Item Type: [% item.item_type %]
385 [% IF user_data.0.type == 'full' && item.holdings.size == 0 %]
386 <li>No items for this record at the selected location</li>
388 [% FOR cp IN item.holdings -%]
390 Library: [% cp.circ_lib %]<br/>
391 Location: [% cp.location %]<br/>
392 Call Number: [% cp.prefix _ ' ' _ cp.callnumber _ ' ' _ cp.suffix %]<br/>
393 [% IF cp.parts %]Parts: [% cp.parts %]<br/>[% END %]
394 Status: [% cp.status_label %]<br/>
395 Barcode: [% cp.barcode %]
404 $$ FROM action_trigger.event_definition WHERE hook = 'biblio.format.record_entry.print' AND active;
406 INSERT INTO action_trigger.event_def_group_member (grp, name, holdings, event_def)
407 SELECT 1, 'Full', TRUE, id FROM action_trigger.event_definition WHERE name = 'biblio.record_entry.print.full' and active;