-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_install.sql
More file actions
409 lines (407 loc) · 15.2 KB
/
Copy pathplugin_install.sql
File metadata and controls
409 lines (407 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
prompt --application/set_environment
set define off verify off feedback off
whenever sqlerror exit sql.sqlcode rollback
--------------------------------------------------------------------------------
--
-- Oracle APEX export file
--
-- You should run this script using a SQL client connected to the database as
-- the owner (parsing schema) of the application or as a database user with the
-- APEX_ADMINISTRATOR_ROLE role.
--
-- This export file has been automatically generated. Modifying this file is not
-- supported by Oracle and can lead to unexpected application and/or instance
-- behavior now or in the future.
--
-- NOTE: Calls to apex_application_install override the defaults below.
--
--------------------------------------------------------------------------------
begin
wwv_flow_imp.import_begin (
p_version_yyyy_mm_dd=>'2024.11.30'
,p_release=>'24.2.14'
,p_default_workspace_id=>8599571480196328
,p_default_application_id=>100
,p_default_id_offset=>10837933611247390
,p_default_owner=>'GEN'
);
end;
/
prompt APPLICATION 100 - Pretius Auto Clone Session
--
-- Application Export:
-- Application: 100
-- Name: Pretius Auto Clone Session
-- Date and Time: 16:33 Sunday March 29, 2026
-- Exported By: MMATERNA
-- Flashback: 0
-- Export Type: Component Export
-- Manifest
-- PLUGIN: 101174674838299143
-- Manifest End
-- Version: 24.2.14
-- Instance ID: 8599369053013135
--
begin
-- replace components
wwv_flow_imp.g_mode := 'REPLACE';
end;
/
prompt --application/shared_components/plugins/dynamic_action/pretius_auto_clone_session
begin
wwv_flow_imp_shared.create_plugin(
p_id=>wwv_flow_imp.id(101174674838299143)
,p_plugin_type=>'DYNAMIC ACTION'
,p_name=>'PRETIUS_AUTO_CLONE_SESSION'
,p_display_name=>'Pretius Auto Clone Session'
,p_category=>'EXECUTE'
,p_plsql_code=>wwv_flow_string.join(wwv_flow_t_varchar2(
'function render(',
' p_dynamic_action in apex_plugin.t_dynamic_action,',
' p_plugin in apex_plugin.t_plugin )',
' return apex_plugin.t_dynamic_action_render_result',
'is',
' l_result apex_plugin.t_dynamic_action_render_result;',
'begin',
' l_result.ajax_identifier := apex_plugin.get_ajax_identifier;',
' l_result.javascript_function := q''~function(){',
' var da = this;',
' if (!window.BroadcastChannel) {',
' return;',
' }',
'',
' if (!window.name) {',
' window.name = "TAB_" + Math.random().toString(36).substring(2);',
' }',
' var tabId = window.name;',
'',
' var channelName = (da.action && da.action.attribute01) || "apex-auto-clone";',
' var DEFAULT_CLONE_MESSAGE = "This tab has been cloned to a new session.";',
' var cloneMessageText = DEFAULT_CLONE_MESSAGE;',
' var cloneMessageKey = "apex-auto-clone-msg:" + (apex.env.APP_ID || "") + ":" + channelName;',
' var cloneMessageTabKey = cloneMessageKey + ":" + tabId;',
' var isOnFlag = function(value){',
' if (value === null || value === undefined) {',
' return false;',
' }',
' var normalized = String(value).trim().toUpperCase();',
' return normalized === "Y" || normalized === "YES" || normalized === "ON" ||',
' normalized === "1" || normalized === "TRUE" || normalized === "T";',
' };',
' var readHashMessage = function(){',
' var h = window.location.hash || "";',
' if (!h || h.length < 2) {',
' return null;',
' }',
' var raw = h.substring(1);',
' var parts = raw.split("&");',
' for (var i = 0; i < parts.length; i++) {',
' var kv = parts[i].split("=");',
' if (kv[0] === "acm") {',
' try {',
' return decodeURIComponent((kv[1] || "").replace(/\\+/g, "%20"));',
' } catch (e) {',
' return kv[1] || "";',
' }',
' }',
' }',
' return null;',
' };',
' var clearHashMessage = function(){',
' if (window.location.hash && window.history && window.history.replaceState) {',
' window.history.replaceState(null, document.title, window.location.pathname + window.location.search);',
' }',
' };',
' var showCloneNotice = function(messageText){',
' if (!messageText) {',
' return;',
' }',
' if (apex.message && apex.message.showErrors) {',
' if (apex.message.clearErrors) {',
' apex.message.clearErrors();',
' }',
' apex.message.showErrors([{',
' type: "error",',
' location: ["page"],',
' message: messageText,',
' unsafe: false',
' }]);',
' return;',
' }',
' if (apex.message && apex.message.showPageSuccess) {',
' apex.message.showPageSuccess(messageText);',
' return;',
' }',
' window.alert(messageText);',
' };',
'',
' try {',
' var pendingCloneMessage = window.sessionStorage && sessionStorage.getItem(cloneMessageKey);',
' if (!pendingCloneMessage && window.localStorage) {',
' pendingCloneMessage = localStorage.getItem(cloneMessageTabKey);',
' }',
' if (pendingCloneMessage) {',
' sessionStorage.removeItem(cloneMessageKey);',
' if (window.localStorage) {',
' localStorage.removeItem(cloneMessageTabKey);',
' }',
' showCloneNotice(pendingCloneMessage);',
' }',
' } catch (e) {',
' }',
' var pendingHashMessage = readHashMessage();',
' if (pendingHashMessage) {',
' clearHashMessage();',
' showCloneNotice(pendingHashMessage);',
' }',
' window.__autoCloneInit = window.__autoCloneInit || {};',
' if (window.__autoCloneInit[channelName]) {',
' return;',
' }',
' window.__autoCloneInit[channelName] = true;',
'',
' var channel = new BroadcastChannel(channelName);',
' channel.onmessage = function(messageEvent){',
' var msg = messageEvent.data;',
' if (!msg) {',
' return;',
' }',
'',
' if (msg.type === "on-page-load" &&',
' msg.sessionId === apex.env.APP_SESSION &&',
' msg.tabId !== tabId) {',
' channel.postMessage({',
' type: "duplicated-tab",',
' sessionId: apex.env.APP_SESSION,',
' targetTabId: msg.tabId',
' });',
' }',
'',
' if (msg.type === "duplicated-tab" &&',
' msg.sessionId === apex.env.APP_SESSION &&',
' msg.targetTabId === tabId) {',
' var qs = window.location.search || "";',
' if (qs.charAt(0) === "?") {',
' qs = qs.substring(1);',
' }',
'',
' try {',
' var usp = new URLSearchParams(qs);',
' var pVal = usp.get("p");',
' if (pVal) {',
' var pParts = pVal.split(":");',
' if (pParts.length >= 8) {',
' if (!usp.get("clear") && pParts[5]) {',
' usp.set("clear", pParts[5]);',
' }',
' var itemNames = (pParts[6] || "").split(",");',
' var itemValues = (pParts[7] || "").split(",");',
' for (var i = 0; i < itemNames.length; i++) {',
' var nm = (itemNames[i] || "").trim();',
' if (nm) {',
' usp.set(nm, itemValues[i] || "");',
' }',
' }',
' }',
' usp.delete("p");',
' qs = usp.toString();',
' }',
' } catch (e) {',
' }',
'',
' apex.server.plugin(',
' da.action.ajaxIdentifier,',
' {',
' x01: qs',
' },',
' {',
' dataType: "json",',
' success: function(pData){',
' if (pData && pData.url) {',
' var redirectUrl = pData.url;',
' var shouldShowCloneMessage = isOnFlag(pData.showMessage);',
' cloneMessageText = (pData.messageText || cloneMessageText || DEFAULT_CLONE_MESSAGE).toString();',
' if (shouldShowCloneMessage) {',
' try {',
' if (window.sessionStorage) {',
' sessionStorage.setItem(cloneMessageKey, cloneMessageText);',
' }',
' if (window.localStorage) {',
' localStorage.setItem(cloneMessageTabKey, cloneMessageText);',
' }',
' } catch (e) {',
' }',
' redirectUrl += (redirectUrl.indexOf("#") === -1 ? "#" : "&") + "acm=" + encodeURIComponent(cloneMessageText);',
' }',
' apex.navigation.redirect(redirectUrl);',
' }',
' },',
' error: function(req, status, err){}',
' }',
' );',
' }',
' };',
'',
' if (window === window.top) {',
' channel.postMessage({',
' type: "on-page-load",',
' sessionId: apex.env.APP_SESSION,',
' tabId: tabId',
' });',
' }',
' }~'';',
' return l_result;',
'end render;',
'',
'function ajax(',
' p_dynamic_action in apex_plugin.t_dynamic_action,',
' p_plugin in apex_plugin.t_plugin )',
' return apex_plugin.t_dynamic_action_ajax_result',
'is',
' l_result apex_plugin.t_dynamic_action_ajax_result;',
' c_default_clone_message constant varchar2(4000) := ''This tab has been cloned to a new session.'';',
' l_qs varchar2(4000) := apex_application.g_x01;',
' l_allow_list varchar2(4000) := upper(nvl(p_dynamic_action.attribute_02, ''''));',
' l_show_msg varchar2(1) := nvl(upper(p_dynamic_action.attribute_03), ''N'');',
' l_msg_text varchar2(4000) := nvl(p_dynamic_action.attribute_04, c_default_clone_message);',
' l_items varchar2(32767);',
' l_values varchar2(32767);',
' l_clear_cache varchar2(4000);',
' l_pair varchar2(4000);',
' l_name varchar2(4000);',
' l_value varchar2(4000);',
' l_url varchar2(32767);',
'',
' function norm_name(p_name in varchar2) return varchar2 is',
' begin',
' return upper(trim(replace(replace(utl_url.unescape(nvl(p_name, '''')), ''"'', ''''), chr(39), '''')));',
' end norm_name;',
'',
' function is_allowed(p_name in varchar2) return boolean is',
' begin',
' if regexp_like(norm_name(p_name), ''^P'' || :APP_PAGE_ID || ''_'') then',
' return true;',
' end if;',
'',
' if l_allow_list is null then',
' return false;',
' end if;',
'',
' return instr('','' || l_allow_list || '','', '','' || norm_name(p_name) || '','') > 0;',
' end is_allowed;',
'',
'begin',
' l_allow_list := replace(replace(regexp_replace(l_allow_list, ''\s+'', ''''), ''"'', ''''), chr(39), '''');',
' l_qs := regexp_replace(l_qs, ''(^|&)session=[^&]*'', ''\1'', 1, 0, ''i'');',
' l_qs := regexp_replace(l_qs, ''(^|&)cs=[^&]*'', ''\1'', 1, 0, ''i'');',
' l_qs := regexp_replace(l_qs, ''^&|&$'', '''');',
'',
' for r in (',
' select regexp_substr(l_qs, ''[^&]+'', 1, level) as pair',
' from dual',
' connect by regexp_substr(l_qs, ''[^&]+'', 1, level) is not null',
' ) loop',
' l_pair := r.pair;',
' if instr(l_pair, ''='') = 0 then',
' continue;',
' end if;',
'',
' l_name := substr(l_pair, 1, instr(l_pair, ''='') - 1);',
' l_value := substr(l_pair, instr(l_pair, ''='') + 1);',
'',
' if lower(l_name) = ''clear'' then',
' l_clear_cache := l_value;',
' elsif is_allowed(l_name) then',
' l_items := l_items || '','' || norm_name(l_name);',
' l_values := l_values || '','' || utl_url.unescape(l_value);',
' end if;',
' end loop;',
'',
' l_items := ltrim(l_items, '','');',
' l_values := ltrim(l_values, '','');',
'',
' l_url := apex_page.get_url(',
' p_page => :APP_PAGE_ID,',
' p_request => ''APEX_CLONE_SESSION'',',
' p_clear_cache => l_clear_cache,',
' p_items => l_items,',
' p_values => l_values );',
'',
' apex_json.open_object;',
' apex_json.write(''url'', l_url);',
' apex_json.write(''showMessage'', l_show_msg);',
' apex_json.write(''messageText'', l_msg_text);',
' apex_json.close_object;',
'',
' return l_result;',
'end ajax;'))
,p_api_version=>2
,p_render_function=>'render'
,p_ajax_function=>'ajax'
,p_substitute_attributes=>true
,p_reference_id=>0
,p_subscribe_plugin_settings=>false
,p_help_text=>'Detects duplicated tabs for the same APEX session and redirects the duplicate tab to a cloned session while preserving allowed URL parameters.'
,p_version_identifier=>'1.0.0'
);
wwv_flow_imp_shared.create_plugin_attribute(
p_id=>wwv_flow_imp.id(101174674838299144)
,p_plugin_id=>wwv_flow_imp.id(101174674838299143)
,p_attribute_scope=>'COMPONENT'
,p_attribute_sequence=>1
,p_display_sequence=>10
,p_prompt=>'Channel Name'
,p_attribute_type=>'TEXT'
,p_is_required=>true
,p_default_value=>'apex-auto-clone'
,p_is_translatable=>false
);
wwv_flow_imp_shared.create_plugin_attribute(
p_id=>wwv_flow_imp.id(101174674838299145)
,p_plugin_id=>wwv_flow_imp.id(101174674838299143)
,p_attribute_scope=>'COMPONENT'
,p_attribute_sequence=>2
,p_display_sequence=>20
,p_prompt=>'Allowed Params (CSV)'
,p_attribute_type=>'TEXT'
,p_is_required=>false
,p_is_translatable=>false
,p_help_text=>'Comma separated list of URL parameter names to keep in addition to P<APP_PAGE_ID>_*.'
);
wwv_flow_imp_shared.create_plugin_attribute(
p_id=>wwv_flow_imp.id(101174674838299146)
,p_plugin_id=>wwv_flow_imp.id(101174674838299143)
,p_attribute_scope=>'COMPONENT'
,p_attribute_sequence=>3
,p_display_sequence=>30
,p_prompt=>'Show Clone Message'
,p_attribute_type=>'CHECKBOX'
,p_is_required=>false
,p_default_value=>'N'
,p_is_translatable=>false
,p_help_text=>'Set to Y to show a success message in the cloned tab after redirect.'
);
wwv_flow_imp_shared.create_plugin_attribute(
p_id=>wwv_flow_imp.id(101174674838299148)
,p_plugin_id=>wwv_flow_imp.id(101174674838299143)
,p_attribute_scope=>'COMPONENT'
,p_attribute_sequence=>4
,p_display_sequence=>40
,p_prompt=>'Clone Message Text'
,p_attribute_type=>'TEXT'
,p_is_required=>false
,p_default_value=>'This tab has been cloned to a new session.'
,p_is_translatable=>false
,p_help_text=>'Custom message shown in the cloned tab when Show Clone Message is enabled.'
);
end;
/
prompt --application/end_environment
begin
wwv_flow_imp.import_end(p_auto_install_sup_obj => nvl(wwv_flow_application_install.get_auto_install_sup_obj, false)
);
commit;
end;
/
set verify on feedback on define on
prompt ...done