DBA Data[Home] [Help]

PACKAGE BODY: APPS.ORACLEAPPS

Source


1 package body OracleApps as
2 /* $Header: ICXSEXB.pls 120.6.12020000.2 2012/10/18 09:01:34 absandhw ship $ */
3 
4 /*
5 ** Private procedures
6 */
7 --  *******************************************
8 --     Procedure Display User (DU)
9 --  *******************************************
10 procedure DU is
11 
12 c_error_message varchar2(2000);
13 err_mesg varchar2(240);
14 err_num number;
15 l_user_id number;
16 
17 begin
18 
19 if icx_sec.validateSession then
20 
21 --- Added security for guest and function security for Preferences SSWA
22 
23    select user_id into l_user_id from icx_sessions
24    where session_id = icx_sec.g_session_id;
25 
26   if l_user_id <> 6 and fnd_function.test('ICX_SSWA_USER_PREFERENCES')
27   then
28 
29  displayWebUser;
30 
31  else
32 
33 
34  fnd_message.set_name('FND','FND_APPSNAV_NO_AVAIL_APPS');
35  c_error_message := fnd_message.get;
36 
37  icx_util.add_error(c_error_message);
38  icx_admin_sig.error_screen(c_error_message);
39 
40 
41 end if;
42  end if;
43 
44 exception
45     when others then
46 
47         err_num := SQLCODE;
48         c_error_message := SQLERRM;
49         select substr(c_error_message,12,512) into err_mesg from dual;
50         icx_util.add_error(err_mesg);
51         icx_admin_sig.error_screen(err_mesg);
52 end;
53 
54 procedure NP is
55 
56 c_error_message varchar2(2000);
57 err_mesg varchar2(240);
58 err_num number;
59 
60 begin
61 
62 displayNewPassword;
63 
64 exception
65     when others then
66         err_num := SQLCODE;
67         c_error_message := SQLERRM;
68         select substr(c_error_message,12,512) into err_mesg from dual;
69         icx_util.add_error(err_mesg);
70         icx_admin_sig.error_screen(err_mesg);
71 end;
72 
73 --  ***********************************************
74 --     Procedure Validate Login (VL) information
75 --  ***********************************************
76 
77 procedure VL(i_1      in      VARCHAR2,
78              i_2      in      VARCHAR2,
79 	          i_3	    in	   VARCHAR2,
80 	          home_url in      VARCHAR2)
81 
82 is
83 
84 
85 --  i_1 - username
86 --  i_2 - password
87 --  i_3 - function_code/function_name
88 
89 n_session_id    	number;
90 l_encrypted_session_id varchar2(150);
91 l_home_url		varchar2(240);
92 l_user_id		number;
93 l_profile_defined	boolean;
94 l_function_id		number;
95 l_message       	varchar2(80);
96 l_language		varchar2(30);
97 l_lang_code 		varchar2(4);
98 l_date_format		varchar2(100);
99 c_string		varchar2(150);
100 c_error_message varchar2(2000);
101 err_mesg varchar2(240);
102 err_num number;
103 l_timer number;
104 e_password_fail		exception;
105 
106 
107 begin
108 
109    l_message := icx_sec.validatePassword(i_1,i_2,n_session_id);
110 
111 
112 
113 if l_message = '0'
114 then
115 
116    l_home_url := home_url;
117 
118    update ICX_SESSIONS
119    set	  HOME_URL = l_home_url
120    where  SESSION_ID = n_session_id;
121 
122    if i_3 is null
123    then
124 
125 	update ICX_SESSIONS
126 	set    HOME_URL = l_home_url
127 	where  SESSION_ID = n_session_id;
128 
129 	displayResps(n_session_id);
130 
131    else
132 
133         update ICX_SESSIONS
134         set    HOME_URL = l_home_url,
135 	       MODE_CODE = 'SLAVE'
136         where  SESSION_ID = n_session_id;
137 
138         select function_id
139         into l_function_id
140         from fnd_form_functions
141         where function_name = i_3;
142 
143         runFunction( l_function_id, n_session_id);
144    end if;
145 end if;
146 
147 exception
148     when others then
149         err_num := SQLCODE;
150         c_error_message := SQLERRM;
151         select substr(c_error_message,12,512) into err_mesg from dual;
152         icx_util.add_error(err_mesg);
153         icx_admin_sig.error_screen(err_mesg);
154 end;
155 
156 --  ***********************************************
157 --      Procedure Display Main Menu (DMM)
158 --  ***********************************************
159 procedure DMM is
160 
161 c_error_message varchar2(2000);
162 err_mesg varchar2(240);
163 err_num number;
164 l_lang_code	varchar2(30);
165 l_session_id	number;
166 l_menu_id	number;
167 l_encrypted_session_id varchar2(150);
168 
169 begin
170 
171    if(icx_sec.validateSession) then
172 	l_session_id := icx_sec.g_session_id;
173 
174 	select	MENU_ID
175 	into	l_menu_id
176 	from	ICX_SESSIONS
177 	where	SESSION_ID = l_session_id;
178 
179 	if l_menu_id is null
180 	then
181             displayResps(l_session_id);
182 	else
183 	    OracleApps.DSM_frame(l_menu_id);
184 	end if;
185 
186    end if;
187 
188 exception
189     when others then
190         err_num := SQLCODE;
191         c_error_message := SQLERRM;
192         select substr(c_error_message,12,512) into err_mesg from dual;
193         icx_util.add_error(err_mesg);
194         icx_admin_sig.error_screen(err_mesg);
195 end;
196 
197 --  ***********************************************
198 --      Procedure Display Root Menu (DRM)
199 --  ***********************************************
200 procedure DRM is
201 
202 c_error_message varchar2(2000);
203 err_mesg varchar2(240);
204 err_num number;
205 
206 begin
207 
208    if(icx_sec.validateSession) then
209         displayResps(icx_sec.g_session_id);
210    end if;
211 
212 exception
213     when others then
214         err_num := SQLCODE;
215         c_error_message := SQLERRM;
216         select substr(c_error_message,12,512) into err_mesg from dual;
217         icx_util.add_error(err_mesg);
218         icx_admin_sig.error_screen(err_mesg);
219 end;
220 
221 --  ***********************************************
222 --     Procedure Update Web User Information (UUI)
223 --  ***********************************************
224 procedure UUI(
225                 i_1     in      varchar2,
226                 i_2     in      varchar2,
227                 i_3     in      varchar2,
228                 i_4     in      varchar2,
229                 i_5     in      varchar2,
230                 i_6     in      varchar2,
231                 i_7     in      varchar2,
232                 i_8     in      VARCHAR2,
233                 i_9     in      varchar2,
234                 i_10    in      varchar2,
235                 i_11    IN      VARCHAR2,
236                 i_12    IN      VARCHAR2) is
237 
238 c_error_message varchar2(2000);
239 err_mesg varchar2(240);
240 err_num number;
241 
242 begin
243     updateWebUser(i_1,i_2,i_3,i_4,i_5,i_6,i_7,i_8,i_9,i_10,i_11,i_12);
244 
245 exception
246     when others then
247         err_num := SQLCODE;
248         c_error_message := SQLERRM;
249         select substr(c_error_message,12,512) into err_mesg from dual;
250         icx_util.add_error(err_mesg);
251         icx_admin_sig.error_screen(err_mesg);
252 end;
253 
254 
255 --  ***********************************************
256 --  function Login
257 --     This function creates a session cookie
258 --    for you, but will not take you to the
259 --    Welcome page.
260 --  ***********************************************
261 
262 function Login(i_1    in      VARCHAR2,
263                i_2    in      VARCHAR2,
264 	            i_3    out     nocopy number)
265 return BOOLEAN
266 is
267 
268 --  i_1 - username
269 --  i_2 - password
270 --  i_3 - session_id
271 
272 n_session_id    	number;
273 l_user_id               number;
274 l_profile_defined       boolean;
275 l_function_id		number;
276 l_message       	varchar2(80);
277 l_language		varchar2(30);
278 l_date_format		varchar2(100);
279 c_string		varchar2(150);
280 c_error_message		varchar2(2000);
281 err_mesg		varchar2(240);
282 err_num			number;
283 
284 begin
285    l_message := icx_sec.validatePassword(
286 				c_user_name	=> i_1,
287 				c_user_password	=> i_2,
288 				n_session_id	=> n_session_id,
289 				c_validate_only	=> 'Y');
290 
291 if l_message = '0'
292 then
293 
294    --  *******************************************
295    --  Here, we need to alter the DATABASE session
296    --  We want the database to return data in the
297    --  appropriate language for the user
298    --  *******************************************
299 
300         -- The following should be set be Profiles
301 
302          select user_id
303            into l_user_id
304            from icx_sessions
305           where session_id = n_session_id;
306 
307         fnd_profile.get_specific(
308                 name_z                  => 'ICX_LANGUAGE',
309                 user_id_z               => l_user_id,
310                 val_z                   => l_language,
311                 defined_z               => l_profile_defined);
312 
313         if l_language is null
314         then
315               /*
316             select       upper(value)
317             into         l_language
318             from         v$nls_parameters
319             where        parameter = 'NLS_LANGUAGE';
320             */
321 
322            l_language:=icx_sec.getNLS_PARAMETER('NLS_LANGUAGE'); -- replaces above select mputman 1574527
323 
324 
325         end if;
326 
327         fnd_profile.get_specific(
328                 name_z                  => 'ICX_DATE_FORMAT_MASK',
329                 user_id_z               => l_user_id,
330                 val_z                   => l_date_format,
331                 defined_z               => l_profile_defined);
332 
333         if l_date_format is null
334         then
335                  /*
336             select       upper(value)
337             into         l_date_format
338             from         v$nls_parameters
339             where        parameter = 'NLS_DATE_FORMAT';
340                */
341             l_date_format:=icx_sec.getNLS_PARAMETER('NLS_DATE_FORMAT'); -- replaces above select mputman 1574527
342 
343 
344         end if;
345 
346         FND_GLOBAL.set_nls_context(
347          p_nls_language => l_language,
348          p_nls_territory =>'AMERICA');
349   --next 4 lines removed in favor of above call -- mputman
350   -- l_date_format  := ''''||l_date_format||'''';
351   -- l_language := ''''||l_language||'''';
352 
353   -- dbms_session.set_nls('NLS_LANGUAGE'   , l_language);
354   -- dbms_session.set_nls('NLS_TERRITORY'  , 'AMERICA');
355 
356 
357 
358 --   dbms_session.set_nls('NLS_DATE_FORMAT', l_date_format);
359 
360 
361    i_3 := n_session_id;
362 
363    return TRUE;
364 else
365    return FALSE;
366 
367 end if;
368 
369 exception
370     when others then
371 /*        err_num := SQLCODE;
372         c_error_message := SQLERRM;
373         select substr(c_error_message,12,512) into err_mesg from dual;
374         icx_util.add_error(err_mesg);
375         icx_admin_sig.error_screen(err_mesg);
376 */
377 	return FALSE;
378 end;
379 
380 --  ***********************************************
381 --     function Login
382 --  ***********************************************
383 
384 function Login(i_1	in	VARCHAR2,
385                i_2	in	VARCHAR2,
386 	            i_3	in	varchar2,
387 	            i_4	OUT nocopy number)
388 return BOOLEAN
389 is
390 
391 --  i_1 - username
392 --  i_2 - password
393 --  i_3 - function_name
394 --  i_4 - session_id
395 
396 n_session_id    	number;
397 l_user_id		number;
398 l_profile_defined       boolean;
399 l_function_id		number;
400 c_function_name		varchar2(80);
401 l_dummy			number;
402 l_message       	varchar2(80);
403 l_language		varchar2(30);
404 l_date_format		varchar2(100);
405 c_string		varchar2(150);
406 c_error_message		varchar2(2000);
407 err_mesg		varchar2(240);
408 err_num			number;
409 
410 begin
411    l_message := icx_sec.validatePassword(
412 				c_user_name	=> i_1,
413 				c_user_password	=> i_2,
414 				n_session_id	=> n_session_id,
415 				c_validate_only	=> 'Y');
416 
417 if l_message = '0'
418 then
419 
420    --  *******************************************
421    --  Here, we need to alter the DATABASE session
422    --  We want the database to return data in the
423    --  appropriate language for the user
424    --  *******************************************
425 
426         -- The following should be set be Profiles
427 
428          select user_id
429            into l_user_id
430            from icx_sessions
431           where session_id = n_session_id;
432 
433         fnd_profile.get_specific(
434                 name_z                  => 'ICX_LANGUAGE',
435                 user_id_z               => l_user_id,
436                 val_z                   => l_language,
437                 defined_z               => l_profile_defined);
438 
439         if l_language is null
440         then
441            /*
442             select       upper(value)
443             into         l_language
444             from         v$nls_parameters
445             where        parameter = 'NLS_LANGUAGE';
446                */
447             l_language:=icx_sec.getNLS_PARAMETER('NLS_LANGUAGE'); -- replaces above select mputman 1574527
448 
449 
450         end if;
451 
452         fnd_profile.get_specific(
453                 name_z                  => 'ICX_DATE_FORMAT_MASK',
454                 user_id_z               => l_user_id,
455                 val_z                   => l_date_format,
456                 defined_z               => l_profile_defined);
457 
458         if l_date_format is null
459         then
460                  /*
461             select       upper(value)
462             into         l_date_format
463             from         v$nls_parameters
464             where        parameter = 'NLS_DATE_FORMAT';
465                */
466             l_date_format:=icx_sec.getNLS_PARAMETER('NLS_DATE_FORMAT'); -- replaces above select mputman 1574527
467 
468 
469         end if;
470         FND_GLOBAL.set_nls_context(
471          p_nls_language => l_language,
472          p_nls_territory =>'AMERICA');
473 
474    --next 4 lines removed in favor of above call. -- mputman
475    --l_date_format  := ''''||l_date_format||'''';
476    --l_language := ''''||l_language||'''';
477    --dbms_session.set_nls('NLS_LANGUAGE'   , l_language);
478    --dbms_session.set_nls('NLS_TERRITORY'  , 'AMERICA');
479 
480 
481 --   dbms_session.set_nls('NLS_DATE_FORMAT', l_date_format);
482 
483    i_4 := n_session_id;
484 
485    select fff.function_id
486      into l_function_id
487      from fnd_form_functions fff
488     where fff.function_name = i_3;
489 
490    update icx_sessions
491       set responsibility_id = NULL,
492           function_id = l_function_id
493     where session_id = n_session_id;
494 
495    return TRUE;
496 else
497    return FALSE;
498 
499 end if;
500 
501 exception
502     when NO_DATA_FOUND
503     then
504        return FALSE;
505     when others then
506 	return FALSE;
507 end;
508 
509 --  *******************************************
510 --     Procedure ForgotPwd
511 --  *******************************************
512 procedure ForgotPwd (c_user_name in varchar2) is
513 
514 c_error_msg              VARCHAR2(2000);
515 c_login_msg              VARCHAR2(2000);
516 email_address            VARCHAR2(240);
517 seq                      NUMBER;
518 p_name varchar2(360)     := c_user_name;
519 p_password               VARCHAR2(30);
520 p_expire_days number     := 1;
521 rno                      VARCHAR2(30);
522 l_auth_mode              VARCHAR2(100);
523 l_user_id                NUMBER;
524 e_parameters             WF_PARAMETER_LIST_T;
525 display_name             varchar2(240);
526 notification_preference  varchar2(240);
527 language                 varchar2(30);
528 territory                varchar2(80);
529 
530 
531 BEGIN
532        SELECT user_id
533        into l_user_id
534        from fnd_user
535        where user_name = upper(c_user_name);
536 
537 BEGIN
538       SELECT 'LDAP'
539       INTO l_auth_mode
540       FROM fnd_user
541       WHERE l_user_id = icx_sec.g_user_id
542       AND upper(encrypted_user_password)='EXTERNAL';
543 
544       EXCEPTION
545       WHEN no_data_found THEN
546       l_auth_mode := 'FND';
547 END;
548 
549       IF l_auth_mode <> 'LDAP' THEN
550      WF_DIRECTORY.GetRoleInfo(upper(c_user_name), display_name, email_address, notification_preference, language, territory);
551 
552       DBMS_RANDOM.initialize(12345);
553 --      p_password := to_char(dbms_random.random);
554       rno := to_number(DBMS_RANDOM.random);
555       p_password := 'P'||rno||'W';
556 
557       htp.img(curl => '/OA_MEDIA/FNDLOGOS.gif',
558               cattributes => 'BORDER=0');
559       htp.tableRowClose;
560       htp.tableClose;
561       htp.line;
562 
563 
564   --Raise the event
565 
566  -- WF_LOG_PKG.wf_debug_flag := TRUE;
567 
568   select ICX_TEXT_S.Nextval into seq from dual;
569 
570   WF_EVENT.AddParameterToList('X_USER_NAME', upper(p_name), e_parameters);
571   WF_EVENT.AddParameterToList('X_UNENCRYPTED_PASSWORD', p_password,
572                                 e_parameters);
573   WF_EVENT.AddParameterToList('X_PASSWORD_LIFESPAN_DAYS', p_expire_days,
574                                e_parameters);
575 
576   WF_EVENT.Raise(p_event_name=>'oracle.apps.fnd.user.password.reset_requested',
577                  p_event_key=>seq, p_parameters=>e_parameters);
578 
579   DBMS_RANDOM.terminate;
580 
581   fnd_message.set_name('ICX','ICX_FORGOT_PASSWORD');
582   c_error_msg := fnd_message.get;
583 
584   if email_address is null
585   then
586 
587    fnd_message.set_name('ICX','ICX_CONTACT_WEBMASTER');
588    c_login_msg := fnd_message.get;
589    fnd_message.set_name('ICX','ICX_EMAIL_ADDRESS_NULL');
590    c_error_msg := fnd_message.get;
591    htp.p(c_login_msg||' '||c_error_msg);
592 
593   else
594   htp.p(c_error_msg||' '||email_address);
595 
596 end if;
597 
598   end if;
599 
600 -- Second phase will allow re-direct to different site to change password
601 -- else if l_auth_mode = 'EXTERNAL'
602 -- then
603 -- get the value of the profile option FND_PASSWORD_EXTERNAL_SITE
604 -- create the link woth this url (redirection to the whatever the
605 -- profile options says. If null give them the standard error message below
606 -- owa_util.redirect_url(l_external_password_site);
607 
608 
609    EXCEPTION
610         when no_data_found then
611         fnd_message.set_name('ICX','ICX_ACCT_EXPIRED');
612         c_error_msg := fnd_message.get;
613         fnd_message.set_name('ICX','ICX_CONTACT_WEBMASTER');
614         c_login_msg := fnd_message.get;
615         htp.img(curl => '/OA_MEDIA/FNDLOGOS.gif',
616         cattributes => 'BORDER=0');
617         htp.tableRowClose;
618         htp.tableClose;
619         htp.line;
620         htp.p(c_error_msg||' '||c_login_msg);
621 
622  END;
623 
624 --  ***********************************************
625 --     Procedure displayLogin
626 --  **********************************************
627 procedure displayLogin(c_message in varchar2,
628 		                 c_display in varchar2,
629 		                 c_logo    in varchar2,
630                        i_direct  IN VARCHAR2,
631                        i_mode    IN NUMBER,
632                        recreate  IN VARCHAR2,
633                        p_home_url IN VARCHAR2)
634 is
635    l_url varchar2(2000);
636 
637    c_session_id            number;
638    c_language_code		varchar2(30);
639    c_title		 	varchar2(80);
640    c_prompts		icx_util.g_prompts_table;
641    l_host_instance varchar2(80);
642    l_agent  varchar2(80);
643    l_user_name VARCHAR2(100);
644    l_parameters	icx_on_utilities.v80_table;
645    l_text VARCHAR2(240);
646    l_session_id            VARCHAR2(240);
647    c_error_msg VARCHAR2(240);
648    c_login_msg VARCHAR2(240);
649    l_url2 VARCHAR2(800);
650    l_home_url VARCHAR2(800);
651    l_maint_mode VARCHAR2(80);
652    l_maint_home_url VARCHAR2(800);
653    l_nls_lang VARCHAR2(30);         --2214212
654    c_nls_language VARCHAR2(40);     --2214212
655    b_hosted BOOLEAN DEFAULT FALSE;
656    l_hosted_profile VARCHAR2(50);
657    l_apps_sso VARCHAR2(20);
658    l_portal        BOOLEAN DEFAULT FALSE;
659    l_portal_sso    BOOLEAN DEFAULT FALSE;
660    l_SSWA          BOOLEAN DEFAULT FALSE;
661    l_SSWA_SSO      BOOLEAN DEFAULT FALSE;
662    l_use_portal    BOOLEAN DEFAULT FALSE;
663    l_temp_id       NUMBER;
664 
665 
666 BEGIN
667 
668 
669 -- 2802333 nlbarlow
670 --bug Dale
671 
672 
673  if fnd_profile.defined('APPLICATIONS_HOME_PAGE')
674   then
675 
676 l_url := fnd_sso_manager.getLoginUrl(requestUrl => i_direct);
677 
678  if recreate is not null
679   then
680 
681  fnd_message.set_name('FND','FND_SESSION_ICX_EXPIRED');
682  c_error_msg := fnd_message.get;
683  fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
684  c_login_msg := fnd_message.get;
685 
686 
687   l_url := l_url||'&'||'errText='||wfa_html.conv_special_url_chars(c_error_msg)||wfa_html.conv_special_url_chars(c_login_msg);
688 
689   else
690 
691   l_url := l_url||'&'||'errText='||wfa_html.conv_special_url_chars(c_message);
692 
693   end if;
694 
695 
696 if p_home_url is not null
697 then
698   l_url := l_url||'&'||'home_url='||wfa_html.conv_special_url_chars(p_home_url);
699 end if;
700 
701 owa_util.mime_header('text/html', FALSE);
702 
703 owa_util.redirect_url(l_url);
704 
705 owa_util.http_header_close;
706 
707     else
708 
709 
710    fnd_profile.get(name    => 'ENABLE_SECURITY_GROUPS',
711                    val     => l_hosted_profile);
712 
713    IF (upper(l_hosted_profile)='HOSTED') THEN
714       b_hosted:=TRUE;
715    END IF;
716 
717 
718    icx_sec.writeAudit;
719 
720    --add redirect code to send to portal and sso if portal agent profile is not null
721    --check SSO_SDK, if null, then check apps_portal
722         fnd_profile.get(name    => 'APPS_SSO',
723                         val     => l_apps_sso);
724         fnd_profile.get(name    => 'APPS_PORTAL',
725                         val     => l_url);
726         fnd_profile.get(name    => 'APPS_MAINTENANCE_MODE',
727                         val     => l_maint_mode);-- check for MAINTENANCE mode
728         l_maint_mode := nvl(l_maint_mode,'NORMAL');
729 
730         IF l_apps_sso = 'PORTAL' THEN
731             l_portal:=TRUE;
732         ELSIF l_apps_sso = 'SSO_SDK' THEN
733             l_portal_sso:=TRUE;
734         ELSIF l_apps_sso = 'SSWA' THEN
735             l_SSWA:=TRUE;
736         ELSIF l_apps_sso = 'SSWA_SSO' THEN
737             l_SSWA_SSO:=TRUE;
738         ELSIF l_apps_sso IS NULL THEN
739             l_SSWA:=TRUE;
740         END IF;
741         IF l_portal OR l_portal_sso THEN
742             l_use_portal:=TRUE;
743             ELSE
744             l_use_portal:=FALSE;
745         END IF;
746 
747    --check to see if we are running in maintenance mode AND that we got here for other than expiry.
748    IF (l_maint_mode <> 'NORMAL') AND (recreate IS NULL) THEN
749 
750 
751       fnd_message.set_name('FND','FND_SESSION_ICX_EXPIRED');
752       c_error_msg := fnd_message.get;
753       SELECT home_url
754          INTO l_home_url
755          FROM icx_parameters;
756 
757       --l_home_url:= wfa_html.conv_special_url_chars(l_home_url);
758 
759       IF l_use_portal THEN --using portal and need to make sure we log out
760          l_home_url:= wfa_html.conv_special_url_chars(l_home_url);
761          l_url2 := wfa_html.conv_special_url_chars(l_url);
762          l_maint_home_url := replace(l_url,'home','wwsec_app_priv.logout?p_done_url='||(nvl(l_home_url,l_url2)));
763 
764       ELSE --not using portal and just need to get to icx_sessions.home_url
765          l_maint_home_url := l_home_url;
766       END IF;
767 
768       owa_util.mime_header('text/html', TRUE);
769       htp.p('<meta http-equiv="Expires" content="-1">');
770       htp.htmlOpen;
771       htp.p('<script>');
772           --comment out these next 2 debug lines
773           -- htp.p('alert("'||l_maint_home_url||'");');
774           -- htp.p('alert("'||nvl(l_url,'NULL')||'");');
775       htp.p('alert("'||c_error_msg||'");');
776       htp.p('top.location="'||l_maint_home_url||'"');
777       htp.p('</script>');
778       htp.htmlClose;
779 
780 
781 
782    ELSE -- not in maintenance mode
783 
784       --begin 2214212 mputman -- try to get lang from icx_sessions when session_id is avail via recreate and set nls context.
785       IF recreate IS NOT NULL THEN
786       l_text := icx_call.decrypt(recreate);
787       icx_on_utilities.unpack_parameters(l_text,l_parameters);
788       l_user_name:=l_parameters(2);
789       l_session_id:=l_parameters(1);
790 BEGIN
791    SELECT nls_language
792       INTO l_nls_lang
793       FROM icx_sessions
794       WHERE session_id=l_session_id;
795    if  l_nls_lang is not null
796    and nvl(icx_sec.g_language_c,'XXXXX') <> l_nls_lang
797    then
798       c_nls_language := l_nls_lang;
799       --c_nls_language := ''''||l_nls_lang||'''';
800       --dbms_session.set_nls('NLS_LANGUAGE'   , c_nls_language); --replaced with call to fnd_global
801       icx_sec.g_language_c:=l_nls_lang;
802       FND_GLOBAL.set_nls_context(p_nls_language =>c_nls_language);
803    end if;
804 
805 
806 
807 EXCEPTION
808    WHEN OTHERS THEN
809       NULL;
810 
811 END;
812    END IF;--recreate is not null
813    --end 2214212 mputman
814    IF (l_use_portal OR L_SSWA_SSO) THEN
815       --get home_url for where to go after portal logout... if null go to apps_portal profile value
816       SELECT home_url
817          INTO l_home_url
818          FROM icx_parameters;
819 
820               l_home_url:= wfa_html.conv_special_url_chars(l_home_url);
821               l_url2 := wfa_html.conv_special_url_chars(l_url);
822               IF l_portal_sso THEN
823               l_url := replace(l_url,'home','wwsec_app_priv.logout?p_done_url='||
824                                 OracleSSWA.SSORedirect((nvl(i_direct,l_url)),(nvl(l_home_url,l_url2))));
825               ELSIF l_sswa_sso THEN
826               l_url := OracleSSWA.SSORedirect((nvl(i_direct,FND_WEB_CONFIG.PLSQL_AGENT||'OracleMyPage.home')),
827                                              (nvl(l_home_url,l_home_url)));
828               ELSE
829               l_url := replace(l_url,'home','wwsec_app_priv.logout?p_done_url='||(nvl(l_home_url,l_url2)));
830               END IF;
831                -- nlbarlow, prevent URL caching, 1755317
832                owa_util.mime_header('text/html', TRUE);
833                htp.p('<meta http-equiv="Expires" content="-1">');
834                htp.htmlOpen;
835                htp.p('<script>');
836                IF recreate IS NOT NULL THEN  --let the user know why they are going to a sign on screen
837                   fnd_message.set_name('FND','FND_SESSION_ICX_EXPIRED');
838                   c_error_msg := fnd_message.get;
839                --   htp.p('<script>');
840                   htp.p('alert("'||c_error_msg||'");');
841                --   htp.p('</script>');
842                ELSE
843                   IF ((c_message IS NOT NULL) AND
844                       (icx_sec.getsessioncookie <>-1)) THEN
845                      htp.p('alert("'||c_message||'");');
846                   END IF;
847                END IF;
848                htp.p('top.location="'||l_url||'"');
849                htp.p('</script>');
850                htp.htmlClose;
851 
852    ELSE --not using PORTAL
853       IF recreate IS NOT NULL THEN  --let the user know why they are going to a sign on screen
854          fnd_message.set_name('FND','FND_SESSION_ICX_EXPIRED');
855          c_error_msg := fnd_message.get;
856          htp.p('<script>');
857          htp.p('alert("'||c_error_msg||'");');
858          htp.p('</script>');
859       END IF;
860 
861 
862    icx_util.getPrompts(601,'ICX_LOGIN',c_title,c_prompts);
863    IF recreate IS NOT NULL THEN
864 
865     --  fnd_message.set_name('FND','FND_SESSION_ICX_EXPIRED');
866     --  c_error_msg := fnd_message.get;
867       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
868       c_login_msg := fnd_message.get;
869 
870       --mputman moved up for 2214212
871 --      l_text := icx_call.decrypt(recreate);
872 --      icx_on_utilities.unpack_parameters(l_text,l_parameters);
873 --      l_user_name:=l_parameters(2);
874 --      l_session_id:=l_parameters(1);
875    ELSE
876       icx_sec.RemoveCookie;
877       END IF;
878 
879    --   htp.htmlOpen;
880 --   htp.headOpen;
881    icx_util.copyright;
882    htp.p('<META Http-Equiv="Pragma" Content="no-cache">');
883    htp.title(c_title);
884 
885    htp.p('<SCRIPT LANGUAGE="JavaScript">');
886 
887    IF recreate IS NOT NULL THEN
888 
889 
890 
891      -- htp.p('if (opener != null) {
892      --           alert("'||c_error_msg||'");
893      --           }');
894       --htp.p('alert("'||c_error_msg||'");');
895 
896        htp.p('function logon_submit()
897         {
898 
899 
900              if (document.Logon1.i_1.value.toUpperCase() == "'||l_user_name||'")
901              {
902              document.Logon3.i_1.value = document.Logon1.i_1.value;
903              document.Logon3.i_2.value = document.Logon2.i_2.value;
904              document.Logon3.submit();
905 
906              }else{
907              window.name="";
908              window.close();
909              }
910              }');
911 
912            --  document.Logon0.i_1.value = document.Logon1.i_1.value;
913            --  document.Logon0.i_2.value = document.Logon2.i_2.value;
914            --  document.Logon0.submit();
915            --  }
916 
917            --	}');
918 
919    ELSE
920    htp.p('function logon_submit()
921         {
922                 document.Logon0.i_1.value = document.Logon1.i_1.value;
923                 document.Logon0.i_2.value = document.Logon2.i_2.value;');
924          IF b_hosted THEN
925          htp.p('document.Logon0.c_sec_grp_id.value = document.site.c_sec_grp_id.value;');
926          END IF;
927          htp.p('document.Logon0.submit();
928 	}');
929    END IF;
930    htp.p('</SCRIPT>');
931 
932    c_session_id := icx_sec.getsessioncookie;
933 
934    --****** if cookie exists, get session id ******--
935 
936     -- when we have corrected how icx_sec.RemoveCookie works,
937     -- we can remove the check for -1 here
938 
939    if (c_session_id > 0)
940    then
941 
942       begin
943         select  b.language_code
944         into    c_language_code
945         from    fnd_languages b,
946                 icx_sessions a
947         where   a.session_id = c_session_id
948         and     b.nls_language = a.nls_language;
949 
950       exception
951         when NO_DATA_FOUND then -- bug 643163, check session exists
952           select        LANGUAGE_CODE
953           into          c_language_code
954           from          FND_LANGUAGES
955           where         INSTALLED_FLAG = 'B';
956 
957       end;
958 
959       htp.p('<SCRIPT LANGUAGE="JavaScript">');
960       htp.p('<!-- Hide from old Browsers');
961       icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpl.htm', c_language_code);
962       htp.p('// -->');
963       htp.p('</SCRIPT>');
964 
965 --      htp.headClose;
966 
967       if c_display = 'IC' and c_logo = 'Y'
968       then
969 	icx_admin_sig.toolbar(language_code => c_language_code);
970       else
971          htp.bodyOpen(icx_admin_sig.background(c_language_code));
972       end if;
973    else
974 
975 
976       -- When cookie does not exist (failed during signin) use background from the US directory
977 
978 --      htp.headClose;
979 --      htp.bodyOpen('/OA_MEDIA/ICXBCKGR.jpg');
980 
981       if c_display = 'IC' and c_logo = 'Y'
982       then
983          htp.img(curl => '/OA_MEDIA/FNDLOGOS.gif',
984                  cattributes => 'BORDER=0');
985 
986          htp.tableRowClose;
987          htp.tableClose;
988          htp.line;
989       end if;
990    end if;
991 
992         IF recreate IS NOT NULL THEN
993            htp.p('<H2>'||c_error_msg||'</H2>');
994            --htp.nl;
995            htp.p('<H2>'||c_login_msg||'</H2>');
996         ELSE
997         htp.p(nvl(c_message,'<H2>'||c_title||'</H2>'));
998         END IF;
999 
1000     l_host_instance := FND_WEB_CONFIG.DATABASE_ID;
1001 
1002 --    select      lower(host_name)||'_'||lower(instance_name)
1003 --    into        l_host_instance
1004 --    from        v$instance;
1005 
1006     l_agent := icx_plug_utilities.getPLSQLagent;
1007 
1008 IF recreate IS NOT NULL THEN
1009 htp.p('<FORM NAME=Logon3 ACTION="OracleApps.recreate_session" METHOD="POST" TARGET="_top">');
1010 htp.formHidden('i_1','');
1011 htp.formHidden('i_2','');
1012 htp.formHidden('p_enc_session',icx_call.encrypt3(l_session_id));
1013 --htp.formHidden('p_mode',i_mode);
1014 htp.formClose;
1015 END IF;
1016 
1017     IF i_direct IS NULL  THEN
1018 htp.p('<FORM NAME=Logon0 ACTION="OracleMyPage.Home" METHOD="POST" TARGET="_top">');
1019 htp.formHidden('i_1','');
1020 htp.formHidden('i_2','');
1021 htp.formHidden('rmode','2');
1022 htp.formHidden('c_sec_grp_id','');
1023 --htp.formHidden('i_direct',i_direct); --mputman 793404
1024 
1025     ELSE
1026 htp.p('<FORM NAME=Logon0 ACTION="OracleMyPage.Home" METHOD="POST" TARGET="_top">');
1027 htp.formHidden('i_1','');
1028 htp.formHidden('i_2','');
1029 --htp.formHidden('rmode','2'); --mputman 793404
1030 htp.formHidden('i_direct',i_direct); --mputman 793404
1031 htp.formHidden('rmode',i_mode); --mputman 793404
1032 htp.formHidden('c_sec_grp_id','');
1033 
1034 
1035     END IF;
1036 
1037 
1038 --htp.p('<FORM NAME=Logon0 ACTION="OracleMyPage.Home" METHOD="POST" TARGET="_top">');
1039 ----htp.formHidden('dbHost',l_host_instance);
1040 ----htp.formHidden('agent',l_agent);
1041 --htp.formHidden('i_1','');
1042 --htp.formHidden('i_2','');
1043 --htp.formHidden('rmode','2');
1044 --htp.formHidden('i_direct',i_direct); --mputman 793404
1045 
1046 
1047 htp.formClose;
1048 
1049 IF b_hosted THEN
1050 htp.tableOpen;
1051    htp.tableRowOpen;                             -- SITE
1052         htp.tableData(c_prompts(5),'RIGHT');
1053         htp.p('<FORM NAME=site ACTION="javascript:document.Logon2.i_2.focus();" METHOD="POST">');
1054         htp.tableData(htf.formText('c_sec_grp_id',30));
1055         htp.formClose;
1056         htp.p('<td></td>');
1057    htp.tableRowClose;
1058 END IF;
1059 
1060 htp.tableOpen;
1061    htp.tableRowOpen;                             -- Username
1062         htp.tableData(c_prompts(1),'RIGHT');
1063         htp.p('<FORM NAME=Logon1 ACTION="javascript:document.Logon2.i_2.focus();" METHOD="POST">');
1064         htp.tableData(htf.formText('i_1',30));
1065         htp.formClose;
1066         htp.p('<td></td>');
1067    htp.tableRowClose;
1068    htp.tableRowOpen;                             -- Password
1069 	htp.tableData(c_prompts(2),'RIGHT');
1070         htp.p('<FORM NAME=Logon2 ACTION="javascript:logon_submit();" METHOD="POST">');
1071 	htp.tableData(htf.formPassword('i_2',30));
1072         htp.formClose;
1073         htp.p('<td>');
1074         icx_plug_utilities.buttonBoth(c_prompts(3),'javascript:logon_submit()','FNDJLFOK.gif'); --  Connect
1075         htp.p('</td>');
1076    htp.tableRowClose;
1077 htp.tableClose;
1078    htp.formClose;
1079 
1080         htp.p('<SCRIPT LANGUAGE="JavaScript">');
1081         htp.p('<!-- Hide from old Browsers');
1082         IF recreate IS NOT NULL THEN
1083            htp.p('document.Logon1.i_1.value="'||l_user_name||'"');
1084            htp.p('document.Logon2.i_2.focus();');
1085 
1086            htp.p('// -->');
1087 
1088            htp.p('function onLoadFunc() {
1089                  document.Logon2.i_2.focus();
1090                  }');
1091            htp.p('</SCRIPT>');
1092            htp.p('<body onLoad="onLoadFunc()"></body>');
1093         ELSE
1094            htp.p('document.Logon1.i_1.focus();');
1095 
1096            htp.p('// -->');
1097            htp.p('</SCRIPT>');
1098 
1099 
1100            END IF;
1101 
1102         END IF;
1103 
1104    END IF;
1105 
1106 end if;
1107 
1108         exception
1109 	when others then
1110 --htp.p(SQLERRM);
1111   htp.p(dbms_utility.format_error_stack);
1112 
1113 end;
1114 
1115 
1116 -- mbukhari Added this signature for API redirectURL to fix bug 2171975. 16-Jan-2002
1117 -- We should keep the old signature for this API around for backward compatibility.
1118 
1119 procedure redirectURL(i_1 in varchar2,
1120                       i_2 in varchar2,
1121                       URL in varchar2,
1122                       F   in varchar2,
1123                       A   in VARCHAR2,
1124                       R   in VARCHAR2,
1125                       S   in VARCHAR2) is
1126 
1127 l_anchor                   varchar2(2000);
1128 l_encrypted_session_id     varchar2(240);
1129 l_encrypted_transaction_id varchar2(240);
1130 l_dbc                      varchar2(240);
1131 l_responsibility_id        number;
1132 l_resp_appl_id             number;
1133 l_security_group_id        number;
1134 l_session_id               number;
1135 l_function_id              number;
1136 l_random_num               number;
1137 l_message                  varchar2(80);
1138 l_result                   varchar2(30);
1139 l_username                 varchar2(30);
1140 l_user_id                  number;
1141 l_error_msg                varchar2(2000);
1142 l_login_msg                varchar2(2000);
1143 l_function_name            varchar2(2000);
1144 l_transaction_id           number;
1145 
1146 cursor getResp(p_user_id in varchar2) is
1147       select  fr.menu_id, furg.responsibility_id,
1148               furg.security_group_id, furg.responsibility_application_id
1149       from    fnd_responsibility fr,
1150               fnd_user_resp_groups furg,
1151               fnd_user fu
1152       where   fu.USER_ID = p_user_id
1153       and     fu.START_DATE <= sysdate
1154       and     (fu.END_DATE is null or fu.END_DATE > sysdate)
1155       and     furg.USER_ID = fu.USER_ID
1156       and     furg.START_DATE <= sysdate
1157       and     (furg.END_DATE is null or furg.END_DATE > sysdate)
1158       and     furg.RESPONSIBILITY_APPLICATION_ID = fr.APPLICATION_ID
1159       and     furg.RESPONSIBILITY_ID = fr.RESPONSIBILITY_ID
1160       and     fr.VERSION = 'W'
1161       and     fr.START_DATE <= sysdate
1162       and     (fr.END_DATE is null or fr.END_DATE > sysdate);
1163 
1164 
1165 cursor getFunctionId(p_function_name in varchar2) is
1166       select function_id
1167       from   fnd_form_functions
1168       where  function_name = p_function_name;
1169 
1170 begin
1171 
1172   l_anchor := URL;
1173   l_function_name := F;
1174   l_username := upper(i_1);
1175 
1176   l_result := fnd_web_sec.validate_login(l_username, i_2);
1177 
1178   if l_result = 'Y'
1179   then
1180     select USER_ID
1181     into   l_user_id
1182     from   FND_USER
1183     where  USER_NAME = l_username;
1184 
1185     if (F is not null)
1186     then
1187       open getFunctionId(l_function_name);
1188       fetch getFunctionId into l_function_id;
1189       close getFunctionId;
1190 
1191       for ri in getResp(l_user_id) loop
1192 
1193         if fnd_function.is_function_on_menu(ri.menu_id, l_function_id)
1194         then
1195           l_resp_appl_id := ri.responsibility_application_id;
1196           l_responsibility_id := ri.responsibility_id;
1197           l_security_group_id := ri.security_group_id;
1198           exit;
1199         end if;
1200       end loop;
1201     else
1202        if A is null
1203        then
1204 	 l_resp_appl_id := '';
1205        else
1206 	 l_resp_appl_id := icx_call.decrypt3(A);
1207        end if;
1208 
1209        if R is null
1210        then
1211 	 l_responsibility_id := '';
1212        else
1213 	 l_responsibility_id := icx_call.decrypt3(R);
1214        end if;
1215 
1216        if S is null
1217        then
1218 	 l_security_group_id := '';
1219        else
1220 	 l_security_group_id := icx_call.decrypt3(S);
1221        end if;
1222 
1223     end if;
1224 
1225 
1226     l_session_id := icx_sec.createSession(p_user_id => l_user_id,
1227                                           c_mode_code   => '115P') ;
1228 
1229 
1230     owa_util.mime_header('text/html', FALSE);
1231 
1232     icx_sec.sendsessioncookie(l_session_id);
1233 
1234     if (instr(l_anchor,'OA.jsp') > 0)
1235     then
1236       fnd_profile.get(name => 'APPS_DATABASE_ID',
1237                       val => l_dbc);
1238 
1239       if l_dbc is null
1240       then
1241         l_dbc := FND_WEB_CONFIG.DATABASE_ID;
1242       end if;
1243 
1244       l_encrypted_session_id := icx_call.encrypt3(l_session_id);
1245 
1246       l_transaction_id :=
1247         icx_sec.createTransaction(
1248         l_session_id,l_resp_appl_id,l_responsibility_id,l_security_group_id,
1249         '','','','');
1250       l_encrypted_transaction_id := icx_call.encrypt3(l_transaction_id);
1251 
1252       icx_sec.updateSessionContext(p_function_name     => l_function_name,
1253                                    p_function_id       => l_function_id,
1254                                    p_application_id    => l_resp_appl_id,
1255                                    p_responsibility_id => l_responsibility_id,
1256                                    p_security_group_id => l_security_group_id,
1257                                    p_session_id        => l_session_id,
1258                                    p_transaction_id    => l_transaction_id);
1259 
1260       l_anchor := l_anchor||
1261                '&'||'dbc='||l_dbc||
1262                '&'||'language_code='||icx_sec.g_language_code||
1263                '&'||'transactionid='||l_encrypted_transaction_id;
1264     end if;
1265 
1266     owa_util.redirect_url(l_anchor);
1267     owa_util.http_header_close;
1268 
1269   else
1270      fnd_message.set_name('ICX','ICX_SIGNIN_INVALID');
1271      l_error_msg := fnd_message.get;
1272      fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
1273      l_login_msg := fnd_message.get;
1274 
1275      OracleApps.displayLogin(l_error_msg||' '||l_login_msg,'IC','Y');
1276   end if;
1277 
1278 exception
1279   when others then
1280 --    htp.p(SQLERRM);
1281    htp.p(dbms_utility.format_error_stack);
1282 
1283 end;
1284 
1285 procedure redirectURL(i_1 in varchar2,
1286                       i_2 in varchar2,
1287                       URL in varchar2,
1288                       A   in VARCHAR2,
1289                       R   in VARCHAR2,
1290                       S   in VARCHAR2) is
1291 
1292 l_anchor                   varchar2(2000);
1293 l_encrypted_session_id     varchar2(240);
1294 l_encrypted_transaction_id varchar2(240);
1295 l_dbc                      varchar2(240);
1296 l_responsibility_id        number;
1297 l_resp_appl_id             number;
1298 l_security_group_id        number;
1299 l_session_id               number;
1300 l_random_num               number;
1301 l_message                  varchar2(80);
1302 l_result                   varchar2(30);
1303 l_username                 varchar2(30);
1304 l_user_id                  number;
1305 l_error_msg                varchar2(2000);
1306 l_login_msg                varchar2(2000);
1307 
1308 begin
1309 
1310   l_anchor := URL;
1311 
1312   if A is null
1313   then
1314     l_resp_appl_id := '';
1315   else
1316     l_resp_appl_id := icx_call.decrypt3(A);
1317   end if;
1318 
1319   if R is null
1320   then
1321     l_responsibility_id := '';
1322   else
1323     l_responsibility_id := icx_call.decrypt3(R);
1324   end if;
1325 
1326   if S is null
1327   then
1328     l_security_group_id := '';
1329   else
1330     l_security_group_id := icx_call.decrypt3(S);
1331   end if;
1332 
1333   l_username := upper(i_1);
1334 
1335   l_result := fnd_web_sec.validate_login(l_username, i_2);
1336 
1337   if l_result = 'Y'
1338   then
1339     select USER_ID
1340     into   l_user_id
1341     from   FND_USER
1342     where  USER_NAME = l_username;
1343 
1344     l_session_id := icx_sec.createSession(p_user_id => l_user_id,
1345                                           c_mode_code   => '115P') ;
1346 
1347     owa_util.mime_header('text/html', FALSE);
1348 
1349     icx_sec.sendsessioncookie(l_session_id);
1350 
1351     if (instr(l_anchor,'OA.jsp') > 0)
1352     then
1353       fnd_profile.get(name => 'APPS_DATABASE_ID',
1354                       val => l_dbc);
1355 
1356       if l_dbc is null
1357       then
1358         l_dbc := FND_WEB_CONFIG.DATABASE_ID;
1359       end if;
1360 
1361       l_encrypted_session_id := icx_call.encrypt3(l_session_id);
1362       l_encrypted_transaction_id :=
1363         icx_call.encrypt3(icx_sec.createTransaction(
1364         l_session_id,l_resp_appl_id,l_responsibility_id,l_security_group_id,
1365         '','','',''));
1366 
1367       l_anchor := l_anchor||
1368                '&'||'dbc='||l_dbc||
1369                '&'||'language_code='||icx_sec.g_language_code||
1370                '&'||'transactionid='||l_encrypted_transaction_id;
1371     end if;
1372 
1373     owa_util.redirect_url(l_anchor);
1374 
1375     owa_util.http_header_close;
1376 
1377   else
1378      fnd_message.set_name('ICX','ICX_SIGNIN_INVALID');
1379      l_error_msg := fnd_message.get;
1380      fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
1381      l_login_msg := fnd_message.get;
1382 
1383      OracleApps.displayLogin(l_error_msg||' '||l_login_msg,'IC','Y');
1384   end if;
1385 
1386 exception
1387   when others then
1388 --    htp.p(SQLERRM);
1389       htp.p(dbms_utility.format_error_stack);
1390 
1391 end;
1392 
1393 
1394 --  ***********************************************
1395 --    Procedure displayResps
1396 --  ***********************************************
1397 procedure displayResps(nri       in VARCHAR2,
1398                        c_toolbar in VARCHAR2)
1399 is
1400 	-- *******************************
1401 	-- nri - Not Required Input
1402 	-- in this case, nri is the session_id
1403 	-- *******************************
1404 
1405         c_menu_id	 	number;
1406 	c_function_id	 	number;
1407         c_anchor        	varchar2(2000);
1408 	l_url			varchar2(2000);
1409 	n_error_num		number;
1410 	c_display_error		varchar2(240);
1411 	c_error_msg		varchar2(2000);
1412 	c_login_msg		varchar2(2000);
1413         c_known_as      	varchar2(240);
1414 	c_user_name		varchar2(100);
1415 	c_user_id		number;
1416 	l_profile_defined       boolean;
1417 	a_counter		number default 0;
1418 	r_counter		binary_integer default 0;
1419 	f_counter		binary_integer default 0;
1420 	c_display		varchar2(80) default 'IC';
1421 	l_session_id		number;
1422 	n_session_id		number;
1423 	p_funcTable		icx_admin_sig.pp_table;
1424 	p_funcEmpty		icx_admin_sig.pp_table;
1425 	b_return		BOOLEAN default TRUE;
1426 	c_title		 	varchar2(80);
1427 	c_language_code		varchar2(30);
1428 	c_prompts		icx_util.g_prompts_table;
1429 	e_data_error		exception;
1430 	n_encryption_passed	number := 1;
1431 	c_encrypted_func	varchar2(2000);
1432 	-- added for images
1433         i_counter               binary_integer default 0;
1434 
1435 	v_color			varchar2(7);
1436 	v_color_image 		varchar2(20);
1437 	v_bullet_image 		varchar2(20);
1438 	l_language 		varchar2(30);
1439 	l_date_format 		varchar2(30);
1440         l_count			number;
1441 	l_function_id		number;
1442 
1443 	-- added to suport menu
1444 	f			fnd_form_functions_vl%rowtype;
1445 	l_menuItems		menuItemTable;
1446 	l_level			number;
1447 	l_encrypt_menu		varchar2(2000);
1448 	l_user_menu_name	varchar2(80);
1449 	l_prompt		varchar2(240);
1450 	l_description		varchar2(240);
1451 
1452         cursor resps is
1453         select  b.RESPONSIBILITY_APPLICATION_ID,
1454                 b.SECURITY_GROUP_ID,
1455                 a.responsibility_id,
1456 		a.responsibility_name,
1457 		a.description,
1458 		a.web_host_name,
1459 		a.web_agent_name,
1460 		a.version,
1461 		a.menu_id
1462 	from	fnd_responsibility_vl a,
1463                 FND_USER_RESP_GROUPS b
1464         where   b.user_id = c_user_id
1465         and     a.responsibility_id = b.responsibility_id
1466 	and	a.application_id = b.RESPONSIBILITY_application_id
1467 	and     a.version = 'W'
1468 	and	a.start_date <= sysdate
1469 	and	(a.end_date is null or a.end_date > sysdate)
1470 	and	b.start_date <= sysdate
1471 	and	(b.end_date is null or b.end_date > sysdate)
1472         order by responsibility_name;
1473 
1474 	-- menuItems is all the menuitems under certain menu
1475 	cursor 	menuItems is
1476 	select 	b.menu_id,
1477 		b.entry_sequence,
1478 		b.sub_menu_id,
1479 		b.function_id,
1480 		c.web_html_call,
1481 		b.prompt,
1482 		b.description,
1483 		c.web_icon
1484 	from 	fnd_form_functions c,
1485 	     	fnd_menu_entries_vl b
1486 	where 	b.menu_id = c_menu_id
1487 	and	c.function_id(+) = b.function_id
1488         and     nvl(c.type,'WWW') in ('WWW','WWK', 'SERVLET','JSP', 'INTEROPJSP')
1489 	order	by b.entry_sequence;
1490 
1491 l_timer number;
1492 begin
1493 
1494 if (nri is not NULL)
1495 then
1496 
1497    n_session_id := nri;
1498 
1499    select       nls_language,date_format_mask
1500    into         l_language,l_date_format
1501    from         icx_sessions
1502    where        session_id = n_session_id;
1503 
1504    l_session_id := n_session_id;
1505         FND_GLOBAL.set_nls_context(
1506          p_nls_language => l_language,
1507          p_nls_territory =>'AMERICA');
1508   --next 4 lines removed in favor of above call -- mputman
1509   -- l_date_format  := ''''||l_date_format||'''';
1510   -- l_language := ''''||l_language||'''';
1511 
1512   -- dbms_session.set_nls('NLS_LANGUAGE'   , l_language);
1513   -- dbms_session.set_nls('NLS_TERRITORY'  , 'AMERICA');
1514 
1515 
1516 --    dbms_session.set_nls('NLS_DATE_FORMAT', l_date_format);
1517 
1518    -- if session is valid
1519 elsif icx_sec.validateSession
1520 then
1521 
1522    -- ************************************
1523    -- *** If session ID is not passed in,
1524    -- *** get the cookie for this session.
1525    -- ************************************
1526 
1527    n_session_id := icx_sec.getsessioncookie;
1528 
1529    if (n_session_id <= 0)
1530    then
1531       fnd_message.set_name('FND','FND_SESSION_ICX_EXPIRED');
1532       c_error_msg := fnd_message.get;
1533       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
1534       c_login_msg := fnd_message.get;
1535 
1536       OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
1537       b_return := FALSE;
1538    end if;
1539 end if;
1540 
1541 if (b_return)
1542 then
1543    icx_sec.writeAudit;
1544 
1545    icx_util.getPrompts(601,'ICX_MAIN_MENU',c_title,c_prompts);
1546 
1547    if (l_session_id is not NULL)    -- This will happen during the login process
1548    then
1549       select b.language_code
1550       into   c_language_code
1551       from   fnd_languages b,
1552              icx_sessions a
1553       where  a.session_id = n_session_id
1554       and    b.nls_language = a.nls_language;
1555    else
1556       c_language_code := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
1557    end if;
1558 
1559    select  a.description, a.user_name, a.user_id
1560    into    c_known_as, c_user_name, c_user_id
1561    from    fnd_user a,
1562            icx_sessions b
1563    where   b.session_id = n_session_id
1564    and     b.user_id    = a.user_id;
1565 
1566    if c_toolbar = 'Y'
1567    then
1568 
1569    htp.htmlOpen;
1570    htp.headOpen;
1571    icx_util.copyright;
1572       js.scriptOpen;
1573       icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpw.htm');
1574       htp.p('function open_new_browser(url,x,y){
1575     attributes = "resizable=yes,scrollbars=yes,toolbar=yes,width="+x+",height="+y;
1576     new_browser = window.open(url, "new_browser", attributes);}');
1577       js.scriptClose;
1578       htp.title(c_title||'  '|| nvl(c_known_as,c_user_name));
1579    htp.headClose;
1580 
1581 	--* use Oracle logo *--
1582    icx_admin_sig.toolbar(language_code => c_language_code,
1583 		         disp_mainmenu => 'N');
1584 
1585    end if; -- c_toolbar = 'Y'
1586 
1587    if c_display = 'IC'
1588    then
1589       htp.p('<H2>'||c_title||'  '|| nvl(c_known_as,c_user_name)||'</H2>');
1590    else
1591       htp.p(c_title||'  '||htf.anchor('OracleApps.DU', nvl(c_known_as, c_user_name)));
1592    end if;
1593 
1594    htp.p('<TABLE WRAP>');
1595 
1596    for r in Resps loop
1597 
1598       c_menu_id := r.menu_id;
1599 
1600       r_counter := r_counter + 1;
1601       if (mod(r_counter,4) = 1) then
1602 	v_color := G_PURPLE;
1603 	v_color_image := 'FNDIPRBR.gif';
1604 	v_bullet_image := 'FNDIPRBL.gif';
1605       elsif (mod(r_counter,4) = 2) then
1606 	v_color := G_RED;
1607 	v_color_image := 'FNDIRDBR.gif';
1608 	v_bullet_image := 'FNDIRDBL.gif';
1609       elsif (mod(r_counter,4) = 3) then
1610 	v_color := G_GREEN;
1611 	v_color_image := 'FNDIGRBR.gif';
1612 	v_bullet_image := 'FNDIGRBL.gif';
1613       elsif (mod(r_counter,4) = 0) then
1614 	v_color := G_BROWN;
1615 	v_color_image := 'FNDIBRBR.gif';
1616 	v_bullet_image := 'FNDIBRBL.gif';
1617       end if;
1618 
1619     -- modified to display HR icons
1620     -- paint responsibility name and color stripe
1621     -- If only one entry with menu and function custom menu handler
1622 
1623     select  count(1)
1624     into    l_count
1625     from    fnd_menu_entries
1626     where   menu_id = c_menu_id
1627     and     function_id is not null
1628     and     sub_menu_id is not null;
1629 
1630     if l_count = 1
1631     then
1632       select  function_id
1633       into    l_function_id
1634       from    fnd_menu_entries
1635       where   menu_id = c_menu_id
1636       and     function_id is not null
1637       and     sub_menu_id is not null;
1638 
1639       htp.tableRowOpen;
1640       htp.tableData('<B><FONT COLOR=' || v_color || '>'||
1641       --mputman convert to execute effort
1642         --htf.anchor('OracleApps.RF?F='||icx_call.encrypt2(r.responsibility_application_id||'*'||r.responsibility_id||'*'||r.security_group_id||'*'||l_function_id||'**]',n_session_id),
1643         htf.anchor('OracleSSWA.Execute?E='||wfa_html.conv_special_url_chars(icx_call.encrypt(r.responsibility_application_id||'*'||r.responsibility_id||'*'||r.security_group_id||'*'||l_function_id||'**]')),
1644         r.responsibility_name,'','TARGET="_top", onMouseOver="window.status='''||icx_util.replace_onMouseOver_quotes(r.description)||''';return true"')||
1645         '</B></FONT>','','','','','4','');
1646       htp.tableRowClose;
1647       htp.tableRowOpen;
1648       htp.tableData('<IMG SRC=/OA_MEDIA/'
1649                  || v_color_image || ' height=3 width=500></B>',
1650                 '','','','','4','');
1651       htp.tableRowClose;
1652 
1653       htp.tableRowOpen;
1654       htp.tableRowClose;
1655 
1656       htp.tableRowOpen;
1657       htp.tableRowClose;
1658 
1659     else -- l_count <> 1
1660 
1661       htp.tableRowOpen;
1662       htp.tableData('<B><FONT COLOR=' || v_color || '>'||r.responsibility_name||'</B></FONT>','','','','','4','');
1663       htp.tableRowClose;
1664       htp.tableRowOpen;
1665       htp.tableData('<IMG SRC=/OA_MEDIA/'
1666                 || v_color_image || ' height=3 width=500></B>',
1667                 '','','','','4','');
1668       htp.tableRowClose;
1669 
1670       -- if HR responsibility, paint while looping through the functions
1671       -- if others, construct the table while looping, and paint at the end
1672 
1673       for mi in menuItems loop
1674 
1675 	l_prompt := null;
1676 	l_description := null;
1677 	if mi.prompt is not null
1678         then
1679 	    l_prompt := mi.prompt;
1680 	    l_description := mi.description;
1681 	elsif mi.description is not null
1682 	then
1683 	    l_prompt := mi.description;
1684 	    l_description := mi.description;
1685 	end if;
1686 
1687 	if l_prompt is not null then
1688 
1689 	if (mi.function_id is not NULL) then
1690 
1691             if (mi.sub_menu_id is NULL) then
1692 		if substr(mi.web_html_call,1,10) = 'javascript'
1693 		then
1694 		    l_url := replace(mi.web_html_call,'"','''');
1695                     l_url := replace(l_url,'[RESPONSIBILITY_ID]',r.responsibility_id);
1696 		else
1697                     --mputman convert to execute effort
1698                     --l_url := 'OracleApps.RF?F='||icx_call.encrypt2(r.responsibility_application_id||'*'||r.responsibility_id||'*'||r.security_group_id||'*'||mi.function_id||'***]', n_session_id);
1699                     l_url := 'OracleApps.RF?F='||icx_call.encrypt2(r.responsibility_application_id||'*'||r.responsibility_id||'*'||r.security_group_id||'*'||mi.function_id||'***]', n_session_id);
1700 		end if;
1701             else
1702 		l_level := 1;
1703                 l_url := 'OracleApps.DSM?Q='||icx_call.encrypt2(l_level+1||'*'||v_color||'*'||v_color_image||'*'||v_bullet_image||'*'
1704 	||r.responsibility_id||'*'||mi.menu_id||'*'||'OracleApps.DRM'||'*'||mi.sub_menu_id||'*'||'OracleApps.DSM'||'**]', n_session_id);
1705             end if;
1706 
1707 	  	if mi.web_icon is not null
1708 		then
1709 		    if i_counter = 0 then
1710 			htp.tableRowOpen;
1711 		    end if;
1712 		    i_counter := i_counter+1;
1713 
1714 		    -- paint 4 icons on one line
1715 		    if ((i_counter <> 1) AND (MOD(i_counter, 4) = 1))
1716 		    then
1717 			htp.tableRowClose;
1718 			htp.tableRowOpen;
1719 		    end if;
1720 
1721 		    htp.p('<TD WRAP ALIGN="CENTER">');
1722                     htp.anchor(curl => l_url,
1723                             ctext =>
1724                                 htf.img(curl => '/OA_MEDIA/'|| mi.web_icon,
1725                                         cattributes => 'BORDER=0',
1726                                         calt => l_prompt)||
1727                                         htf.br||
1728                                         l_prompt,
1729                             cattributes =>
1730                             'TARGET="_top", onMouseOver="window.status='''||
1731                             icx_util.replace_onMouseOver_quotes(l_description)||
1732 			    ''';return true"');
1733 		    htp.p('</TD>');
1734 
1735 	 	else -- mi.web_icon is null
1736 
1737 		    f_counter := f_counter+1;
1738                     p_funcTable(f_counter) := htf.anchor(l_url,l_prompt,'','TARGET="_top", onMouseOver="window.status='''||icx_util.replace_onMouseOver_quotes(l_description)||''';return true"');
1739 
1740                 end if; -- mi.web_icon
1741 
1742 
1743 	elsif (mi.sub_menu_id is not NULL) then -- sub menu
1744 
1745 	    f_counter := f_counter+1;
1746 
1747 	    l_level := 1;
1748 	    l_encrypt_menu := icx_call.encrypt2(l_level+1||'*'||v_color||'*'||v_color_image||'*'||v_bullet_image||'*'||r.responsibility_id||'*'||mi.menu_id||'*'||'OracleApps.DRM'||'*'||mi.sub_menu_id||'*'||'OracleApps.DSM'||'**]', n_session_id);
1749 	    p_funcTable(f_counter) := htf.anchor('OracleApps.DSM?Q='||l_encrypt_menu, l_prompt, '','TARGET="_top", onMouseOver="window.status='''||icx_util.replace_onMouseOver_quotes(l_description)||''';return true"');
1750 
1751 	else
1752 	    raise e_data_error;
1753 	end if; -- function or menu
1754 	end if; -- no prompts
1755 
1756       end loop; -- Menu items
1757 
1758       -- if there's image associated menu entries
1759       if  i_counter > 0
1760       then
1761 	  htp.tableRowClose;
1762       end if;
1763 
1764       -- if there's text URL associated menu entries
1765       if f_counter > 0
1766       then
1767           icx_admin_sig.displayTable(p_funcTable,f_counter,2, c_language_code,v_bullet_image);
1768       end if;
1769     end if;  -- l_count = 1
1770 
1771       htp.tableRowOpen;
1772       htp.tableData('','','','','','4','');
1773       htp.tableRowClose;
1774 
1775       p_funcTable := p_funcEmpty;       -- reset pl/sql table
1776       f_counter := 0;
1777       i_counter := 0;
1778 
1779       htp.tableRowOpen;
1780       htp.tableRowClose;
1781 
1782    end loop; -- Responsiblities
1783    htp.tableClose;
1784 
1785    if c_toolbar = 'Y'
1786    then
1787 
1788    htp.bodyClose;
1789    htp.htmlClose;
1790 
1791    end if; -- c_toolbar = 'Y'
1792 
1793 end if;
1794 
1795 exception
1796    when e_data_error
1797    then
1798        fnd_message.set_name('ICX','ICX_DATA_INCORRECT');
1799        c_error_msg := fnd_message.get;
1800        Fnd_message.set_name('ICX','ICX_CONTACT_WEBMASTER');
1801        c_login_msg := fnd_message.get;
1802 
1803        OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
1804    when others
1805    then
1806       if n_encryption_passed = 1
1807       then
1808          -- *************************
1809          --  something else failed
1810          -- *************************
1811          fnd_message.set_name('ICX','ICX_SESSION_FAILED');
1812          c_error_msg := fnd_message.get;
1813          fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
1814          c_login_msg := fnd_message.get;
1815 
1816          OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
1817       else
1818          -- *************************
1819          -- encryption failed
1820          -- *************************
1821 
1822               n_error_num := SQLCODE;
1823               c_error_msg := SQLERRM;
1824               select substr(c_error_msg,12,512) into c_display_error from dual;
1825               icx_util.add_error(c_display_error);
1826               icx_admin_sig.error_screen(c_display_error);
1827       end if;
1828 end;
1829 
1830 
1831 procedure DSM(Q in      varchar2) is
1832 
1833 c_title                         varchar2(80);
1834 c_prompts                       icx_util.g_prompts_table;
1835 p_lang_code			varchar2(30);
1836 
1837 begin
1838 
1839     OracleApps.DSM_frame(Q);
1840 
1841 end DSM;
1842 
1843 
1844 --  ***********************************************
1845 --     procedure displaySubmenu
1846 --  ***********************************************
1847 
1848 procedure DSM_frame(Q		in	varchar2) is
1849 
1850 l_userMenuName		varchar2(80);
1851 l_menuURL		varchar2(2000);
1852 l_level			number;
1853 l_menuItems             menuItemTable;
1854 l_resp_appl_id          number;
1855 l_responsibility_id	number;
1856 l_security_group_id     number;
1857 Y 			varchar2(2000);
1858 params 			icx_on_utilities.v80_table;
1859 pass_ons		varchar2(2000);
1860 v_color			varchar2(7);
1861 v_color_image           varchar2(20);
1862 v_bullet_image          varchar2(20);
1863 l_encrypt_string	varchar2(2000);
1864 l_temp_name		varchar2(2000);
1865 l_temp_string		varchar2(2000);
1866 c_language_code		varchar2(30);
1867 l_menu_id		number;
1868 c_function_id           number;
1869 c_encrypted_func        varchar2(2000);
1870 l_encrypt_menu		varchar2(2000);
1871 i_counter		binary_integer default 0;
1872 f_counter		binary_integer default 0;
1873 l_user_menu_name        varchar2(80);
1874 n_session_id		number;
1875 l_menu_name		varchar2(240);
1876 l_menu_description	varchar2(240);
1877 
1878 -- error handling
1879 e_data_error		exception;
1880 n_encryption_passed	number := 1;
1881 c_error_msg             varchar2(2000);
1882 c_login_msg             varchar2(2000);
1883 c_display_error         varchar2(240);
1884 n_error_num             number;
1885 
1886 -- non scalar type
1887 f                       fnd_form_functions_vl%rowtype;
1888 p_funcTable             icx_admin_sig.pp_table;
1889 p_funcEmpty             icx_admin_sig.pp_table;
1890 l_prompt		varchar2(30);
1891 l_description		varchar2(240);
1892 
1893 cursor 	menuItems is
1894 select 	a.menu_id,
1895 	a.entry_sequence,
1896 	a.sub_menu_id,
1897 	a.function_id,
1898 	b.web_html_call,
1899         a.prompt,
1900         a.description,
1901 	b.web_icon
1902 from 	fnd_form_functions b,
1903 	fnd_menu_entries_vl a
1904 where 	a.menu_id = l_menu_id
1905 and	a.function_id = b.function_id(+)
1906 order   by a.entry_sequence;
1907 
1908 begin
1909 
1910 if icx_sec.validateSession
1911 then
1912 
1913 if Q is not null
1914 then
1915     c_language_code := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
1916 
1917     Y:=icx_call.decrypt2(Q);
1918     icx_on_utilities.unpack_parameters(Y, params);
1919 
1920 -- DEBUG --
1921 --    htp.p('Length of params = '||params.count);
1922 --    htp.nl;
1923 
1924     l_level := to_number(params(1));
1925     v_color := params(2);
1926     v_color_image := params(3);
1927     v_bullet_image := params(4);
1928     l_resp_appl_id := to_number(params(5));
1929     l_responsibility_id := to_number(params(6));
1930     l_security_group_id := to_number(params(7));
1931 /*
1932 	8 = menu_id
1933 	9 = menu handler
1934 	10 = sub_menu_id
1935 	11 - sunb menu handler
1936 */
1937 
1938 /*
1939     htp.p('table size='||params.COUNT);
1940     htp.nl;
1941     htp.p('l_level='||l_level);
1942     htp.nl;
1943     htp.p('v_color='||v_color);
1944     htp.nl;
1945     htp.p('v_color_image='||v_color_image);
1946     htp.nl;
1947     htp.p('v_bullet_image='||v_bullet_image);
1948     htp.nl;
1949     htp.p('l_responsibility_id='||l_responsibility_id);
1950     htp.nl;
1951 
1952 */
1953 
1954     l_encrypt_string := params(1)||'*'||params(2)||'*'||params(3)||'*'||
1955 			params(4)||'*'||params(5)||'*'||params(6)||'*'||
1956 			params(7)||'*'||params(8)||'*'||params(9);
1957 
1958     -- initialize menu items table
1959     for i in 1..l_level loop
1960 	l_menuItems(i).menuId := to_number(params(2*i+6));
1961 	l_menuItems(i).menuURL := params(2*i+7);
1962 
1963 	if i = 1
1964 	then
1965 	-- get responsibilty name if root menu
1966 	    select RESPONSIBILITY_NAME, DESCRIPTION
1967 	    into   l_menu_name, l_menu_description
1968 	    from   fnd_responsibility_vl
1969 	    where  RESPONSIBILITY_ID = l_responsibility_id;
1970 	else
1971 	-- get the user menu name for the given menu id
1972 	    select PROMPT, DESCRIPTION
1973 	    into   l_menu_name, l_menu_description
1974 	    from   fnd_menu_entries_vl
1975 	    where  MENU_ID = l_menuItems(i-1).menuId
1976 	    and    SUB_MENU_ID = l_menuItems(i).menuId;
1977 	end if;
1978 
1979 	if l_menu_name is null
1980 	then
1981 	    l_menu_name := l_menu_description;
1982 	end if;
1983 	l_menuItems(i).userMenuName := l_menu_name;
1984 
1985 	-- construct the temporary that contains 1..i-1
1986 	-- concatenation of the menuId and menuURL pairs
1987 	if i=1 then
1988 	    l_temp_string := l_menuItems(i).menuId||'*'||l_menuItems(i).menuURL;
1989 	else
1990 	    l_temp_string := l_temp_string||'*'||l_menuItems(i).menuId||'*'||l_menuItems(i).menuURL;
1991 	end if;
1992 
1993 	l_encrypt_string := i||'*'||v_color||'*'||v_color_image||'*'||v_bullet_image||'*'||l_resp_appl_id||'*'||l_responsibility_id||'*'||l_security_group_id||'*'||l_temp_string;
1994 	n_encryption_passed := 0;
1995 	pass_ons := icx_call.encrypt2(l_encrypt_string||'**]');
1996 	n_encryption_passed := 1;
1997 	-- at most three levels of menu on one line
1998 	if ((i <> 1) and (MOD(i,3) = 1)) then
1999 	    l_temp_name := l_temp_name||'<BR>';
2000 	end if;
2001 
2002 	if i = 1 then
2003 	    l_temp_name := htf.anchor(l_menuItems(i).menuURL, l_menuItems(i).userMenuName,'','onMouseOver= "window.status='''||l_menu_description||''';return true" TARGET="_top"');
2004 	elsif i = l_level then
2005 	    -- record the menu id for the current menu
2006 	    l_menu_id := l_menuItems(i).menuId;
2007 	    l_temp_name := l_temp_name||' : '||l_menuItems(i).userMenuName;
2008 	else
2009 	    l_temp_name := l_temp_name||' : '||htf.anchor(l_menuItems(i).menuURL||'?Q='||pass_ons, l_menuItems(i).userMenuName,'','onMouseOver= "window.status='''||l_menu_description||''';return true" TARGET="_top"');
2010 	end if;
2011     end loop;
2012 
2013     htp.htmlOpen;
2014     htp.headOpen;
2015     icx_util.copyright;
2016 	js.scriptOpen;
2017         icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpw.htm');
2018         js.scriptClose;
2019 	js.scriptOpen;
2020 	htp.p('function new_browser(url,x,y)
2021     {
2022     attributes = "resizable=yes,scrollbars=yes,toolbar=yes,width="+x+",height="+y;
2023     new_browser = window.open(url, "new_browser", attributes);
2024     };');
2025         js.scriptClose;
2026 	htp.title(l_menu_name);
2027     htp.headClose;
2028 
2029     icx_admin_sig.toolbar(language_code => c_language_code,
2030 			  disp_mainmenu => 'N');
2031 
2032     htp.tableOpen('','','','','');
2033     htp.tableRowOpen;
2034     htp.tableData('<B><FONT COLOR=' || v_color || '>'||l_temp_name||'</B></FONT>','','','','','4','');
2035     htp.tableRowClose;
2036     htp.tableRowOpen;
2037     htp.tableData('<IMG SRC=/OA_MEDIA/'
2038                 || v_color_image || ' height=3 width=500></B>',
2039                 '','','','','4','');
2040     htp.tableRowClose;
2041 
2042       for mi in menuItems loop
2043 
2044         l_prompt := null;
2045         l_description := null;
2046         if mi.prompt is not null
2047         then
2048             l_prompt := mi.prompt;
2049             l_description := mi.description;
2050         elsif mi.description is not null
2051         then
2052             l_prompt := mi.description;
2053             l_description := mi.description;
2054         end if;
2055 
2056 	if l_prompt is not null then
2057          if ((mi.sub_menu_id is NULL) AND (mi.function_id is not NULL)) then
2058 
2059 		n_encryption_passed := 0;
2060 
2061       c_encrypted_func := icx_call.encrypt2(l_resp_appl_id||'*'||l_responsibility_id||'*'||l_security_group_id||'*'||mi.function_id||'*'||Q||'**]');
2062 
2063 		n_encryption_passed := 1;
2064 
2065 		if mi.web_icon is not null
2066                 then
2067                     if i_counter = 0 then
2068                         htp.tableRowOpen;
2069                     end if;
2070                     i_counter := i_counter+1;
2071 
2072                     -- paint 4 icons on one line
2073                     if ((i_counter <> 1) AND (MOD(i_counter, 4) = 1))
2074                     then
2075                         htp.tableRowClose;
2076                         htp.tableRowOpen;
2077                     end if;
2078 
2079 		    htp.tabledata
2080                     (htf.anchor(curl => 'OracleApps.RF?F='||c_encrypted_func,
2081                             ctext =>
2082                                 htf.img(curl => '/OA_MEDIA/'|| mi.web_icon,
2083                                         cattributes => 'BORDER=0',
2084                                         calt => l_prompt)||
2085                                         htf.br||
2086                                         l_prompt,
2087                             cattributes =>
2088                             'TARGET="_top", onMouseOver="window.status='''||
2089                             icx_util.replace_onMouseOver_quotes(l_description)||
2090                             ''';return true"'),
2091                             calign      => 'center');
2092                 else -- if no image associated to function
2093 
2094                     f_counter := f_counter+1;
2095 		    if substr(mi.web_html_call,1,10) = 'javascript'
2096 		    then
2097                         p_funcTable(f_counter) := htf.anchor(replace(mi.web_html_call,'"',''''),l_prompt,'','TARGET="_top", onMouseOver="window.status='''||icx_util.replace_onMouseOver_quotes(l_description)||''';return true"');
2098 		    else
2099                         p_funcTable(f_counter) := htf.anchor('OracleApps.RF?F='||c_encrypted_func,l_prompt,'','TARGET="_top", onMouseOver="window.status='''||icx_util.replace_onMouseOver_quotes(l_description)||''';return true"');
2100 		    end if;
2101 
2102                 end if; -- mi.web_icon is not null
2103 
2104          elsif ((mi.function_id is NULL) AND (mi.sub_menu_id is not NULL)) then
2105 -- sub menu
2106 	    -- menu info. for next level
2107 
2108 	    f_counter := f_counter+1;
2109 
2110 	    n_encryption_passed := 0;
2111 	    l_encrypt_menu := icx_call.encrypt2(l_level+1||'*'||v_color||'*'||v_color_image||'*'||v_bullet_image||'*'||l_resp_appl_id||'*'||l_responsibility_id||'*'||l_security_group_id||'*'||l_temp_string||'*'||mi.sub_menu_id||'*'||'OracleApps.DSM'||'**]');
2112 	    n_encryption_passed := 1;
2113 
2114             p_funcTable(f_counter) := htf.anchor('OracleApps.DSM?Q='||l_encrypt_menu, l_prompt, '','TARGET="_top", onMouseOver="window.status='''||icx_util.replace_onMouseOver_quotes(l_description)||''';return true"');
2115 
2116         elsif ((mi.function_id is not NULL) AND (mi.sub_menu_id is not NULL)) then
2117 -- sub menu with function (icon)
2118 
2119             -- menu info. for next level
2120 
2121             n_encryption_passed := 0;
2122             l_encrypt_menu := icx_call.encrypt2(l_level+1||'*'||v_color||'*'||v_color_image||'*'||v_bullet_image||'*'||l_resp_appl_id||'*'||
2123                               l_responsibility_id||'*'||l_security_group_id||'*'||l_temp_string||'*'||mi.sub_menu_id||'*'||'OracleApps.DSM'||'**]');
2124             n_encryption_passed := 1;
2125 
2126                 if mi.web_icon is not null
2127                 then
2128                     if i_counter = 0 then
2129                         htp.tableRowOpen;
2130                     end if;
2131                     i_counter := i_counter+1;
2132 
2133                     -- paint 4 icons on one line
2134                     if ((i_counter <> 1) AND (MOD(i_counter, 4) = 1))
2135                     then
2136                         htp.tableRowClose;
2137                         htp.tableRowOpen;
2138                     end if;
2139 
2140                     htp.tabledata
2141                     (htf.anchor(curl => 'OracleApps.DSM?Q='||l_encrypt_menu,
2142                             ctext =>
2143                                 htf.img(curl => '/OA_MEDIA/'|| mi.web_icon,
2144                                         cattributes => 'BORDER=0',
2145                                         calt => l_prompt)||
2146                                         htf.br||
2147                                         l_prompt,
2148                             cattributes =>
2149                             'TARGET="_top", onMouseOver="window.status='''||
2150                             icx_util.replace_onMouseOver_quotes(l_description)||
2151                             ''';return true"'),
2152                             calign      => 'center');
2153 
2154                 else -- mi.web_icon is null
2155 
2156 		    f_counter := f_counter+1;
2157                     p_funcTable(f_counter) := htf.anchor('OracleApps.DSM?Q='||l_encrypt_menu, l_prompt, '','TARGET="_top", onMouseOver="window.status='''||icx_util.replace_onMouseOver_quotes(l_description)||''';return true"');
2158 
2159                 end if; -- mi.web_icon
2160 
2161          else
2162             raise e_data_error;
2163          end if;
2164 	end if; -- No Prompt
2165 
2166       end loop; -- Menu Items
2167 
2168             -- if there's image associated menu entries
2169       if  i_counter > 0
2170       then
2171           htp.tableRowClose;
2172       end if;
2173 
2174       -- if there's text URL associated menu entries
2175       if f_counter > 0
2176       then
2177           icx_admin_sig.displayTable(p_funcTable,f_counter,2, c_language_code,v_bullet_image);
2178       end if;
2179 
2180       p_funcTable := p_funcEmpty;       -- reset pl/sql table
2181       f_counter := 0;
2182       i_counter := 0;
2183 
2184     htp.tableClose;
2185     htp.bodyClose;
2186     htp.htmlClose;
2187 
2188 end if;
2189 end if;
2190 
2191 exception
2192    when e_data_error
2193    then
2194        fnd_message.set_name('ICX','ICX_DATA_INCORRECT');
2195        c_error_msg := fnd_message.get;
2196        Fnd_message.set_name('ICX','ICX_CONTACT_WEBMASTER');
2197        c_login_msg := fnd_message.get;
2198 
2199        OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
2200    when others
2201    then
2202       if n_encryption_passed = 1
2203       then
2204          -- *************************
2205          --  something else failed
2206          -- *************************
2207          fnd_message.set_name('ICX','ICX_SESSION_FAILED');
2208          c_error_msg := fnd_message.get;
2209          fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
2210          c_login_msg := fnd_message.get;
2211 
2212          OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
2213       else
2214          -- *************************
2215          -- encryption failed
2216          -- *************************
2217 
2218               n_error_num := SQLCODE;
2219               c_error_msg := SQLERRM;
2220               select substr(c_error_msg,12,512) into c_display_error from dual;
2221               icx_util.add_error(c_display_error);
2222               icx_admin_sig.error_screen(c_display_error);
2223       end if;
2224 
2225 end DSM_frame;
2226 
2227 procedure LF(F in      VARCHAR2,
2228              P in      VARCHAR2,
2229              E IN      VARCHAR2) is
2230    --mputman 1545083
2231    --F is old style launch from forms using encrypt
2232    --E is new style launch from forms using encrypt2
2233 
2234 l_parameters	icx_on_utilities.v80_table;
2235 l_text		varchar2(2000);
2236 l_user_id	number;
2237 l_session_id	number;
2238 l_resp_appl_id	varchar2(30);
2239 l_responsibility_id varchar2(30);
2240 l_security_group_id varchar2(30);
2241 l_function_id	varchar2(30);
2242 l_ip_address            varchar2(50);
2243 l_profile_defined	boolean;
2244 l_encrypted_function varchar2(600);
2245 l_URL           varchar2(2000);
2246 err_mesg varchar2(240);
2247 
2248 begin
2249 
2250 IF E IS NOT NULL THEN
2251 	-- mputman 1545083
2252 	-- new call from forms using decrypt2
2253 	-- session_id of -99 must be used from forms for decrypt2 to work
2254 	l_text := icx_call.decrypt2(E,-99);
2255 delete from icx_text where text_id=E;commit;     --mputman added 1545083
2256 ELSE
2257 	l_text := icx_call.decrypt(F);
2258 
2259 END IF;
2260 
2261 icx_on_utilities.unpack_parameters(l_text,l_parameters);
2262 
2263 l_user_id :=  l_parameters(1);
2264 l_resp_appl_id := l_parameters(2);
2265 l_responsibility_id := l_parameters(3);
2266 l_security_group_id := l_parameters(4);
2267 l_function_id := l_parameters(5);
2268 
2269 IF icx_sec.validatesession THEN
2270 
2271    l_session_id := icx_sec.getsessioncookie;
2272    --mputman convert to execute effort
2273    --l_encrypted_function := icx_call.encrypt2(l_resp_appl_id||'*'||l_responsibility_id||'*'||
2274 	--                     	l_security_group_id||'*'||l_function_id||'***]',l_session_id);
2275 
2276    l_encrypted_function := wfa_html.conv_special_url_chars(icx_call.encrypt(l_resp_appl_id||'*'||l_responsibility_id||'*'||
2277 	                     	l_security_group_id||'*'||l_function_id||'***]'));
2278    --mputman convert to execute effort
2279    --l_URL := 'OracleApps.RF?F='||l_encrypted_function;
2280    l_URL := 'OracleSSWA.Execute?E='||l_encrypted_function;
2281    if P is not null
2282       then
2283 --      l_URL := l_URL||'&'||'P='||icx_call.encrypt2(icx_call.decrypt(P),l_session_id);
2284       l_URL := l_URL||'&'||'P='||P;
2285       end if;
2286       htp.bodyOpen(cattributes => 'onLoad="top.location='''||l_URL||'''"');
2287       htp.bodyClose;
2288 
2289 ELSE
2290 
2291    --following code was removed as applications standard method for connection is via PHP or Portal
2292    -- per bug 2065286 mputman
2293 
2294     --to re-enable pseudo sessions, uncomment the following block of code
2295 /*
2296   l_session_id := icx_sec.createSession(l_user_id);
2297   l_encrypted_function := icx_call.encrypt2(l_resp_appl_id||'*'||l_responsibility_id||'*'||
2298   l_security_group_id||'*'||l_function_id||'***]',l_session_id);
2299   owa_util.mime_header('text/html', FALSE);
2300   icx_sec.sendsessioncookie(l_session_id);
2301   owa_util.http_header_close;
2302   l_URL := 'OracleApps.RF?F='||l_encrypted_function;
2303   if P is not null
2304   then
2305     l_URL := l_URL||'&'||'P='||icx_call.encrypt2(icx_call.decrypt(P),l_session_id);
2306   end if;
2307   htp.bodyOpen(cattributes => 'onLoad="top.location='''||l_URL||'''"');
2308   htp.bodyClose;
2309 */
2310    NULL;
2311 END IF;   -- if added to support timeout feature.. if there is a session, use it, else create pseudo. mputman
2312 
2313 
2314 
2315 exception
2316 when NO_DATA_FOUND then   --mputman added 1545083
2317         fnd_message.set_name('ICX','ICX_SESSION_FAILED');
2318         err_mesg := fnd_message.get;
2319         icx_util.add_error(err_mesg);
2320         icx_admin_sig.error_screen(err_mesg);
2321 
2322 when others then
2323 --htp.p(SQLERRM);
2324   htp.p(dbms_utility.format_error_stack);
2325 
2326 end;
2327 
2328 --  ***********************************************
2329 --     function createRFLink
2330 --  ***********************************************
2331 function createRFLink(p_text                   varchar2,
2332                       p_application_id         number,
2333                       p_responsibility_id      number,
2334                       p_security_group_id      number,
2335                       p_function_id            number,
2336                       p_target                 VARCHAR2,
2337                       p_session_id             NUMBER)
2338                       return varchar2 is
2339 
2340 PRAGMA AUTONOMOUS_TRANSACTION;
2341 
2342 l_RFLink       varchar2(2000);
2343 
2344 begin
2345 
2346   -- 2758891 nlbarlow
2347   l_RFLink := icx_portlet.createExecLink(p_application_id => p_application_id,
2348                        p_responsibility_id => p_responsibility_id,
2349                        p_security_group_id => p_security_group_id,
2350                        p_function_id => p_function_id,
2351                        p_parameters => '',
2352                        p_target => p_target,
2353                        p_link_name => p_text,
2354                        p_url_only => 'N');
2355 
2356   return l_RFlink;
2357 
2358 end createRFLink;
2359 
2360 
2361 --  ***********************************************
2362 --     procedure RF
2363 --  ***********************************************
2364 
2365 procedure RF(F in      varchar2,
2366              P in      VARCHAR2) is
2367 
2368 l_url varchar2(2000);
2369 l_session_id number;
2370 l_text varchar2(2000);
2371 l_parameters    icx_on_utilities.v80_table;
2372 l_resp_appl_id number;
2373 l_responsibility_id number;
2374 l_security_group_id number;
2375 l_function_id number;
2376 
2377 /*
2378 l_text varchar2(2000);
2379 l_parameters    icx_on_utilities.v80_table;
2380 l_resp_appl_id number;
2381 l_responsibility_id number;
2382 l_security_group_id number;
2383 l_function_id number;
2384 l_function_type varchar2(30);
2385 l_menu_id number;
2386 l_session_id number;
2387 l_validate          boolean;
2388 l_error_message varchar2(2000);
2389 err_mesg varchar2(240);
2390 err_num number;
2391 l_user_id               number;
2392 l_org_id		number;
2393 l_multi_org_flag	varchar2(30);
2394 l_profile_defined	boolean;
2395 e_session_invalid       exception;
2396 */
2397 
2398 begin
2399 
2400   l_session_id := icx_sec.getID(icx_sec.pv_session_id);
2401 
2402   l_text := icx_call.decrypt2(F,l_session_id);
2403 
2404   icx_on_utilities.unpack_parameters(l_text,l_parameters);
2405   l_resp_appl_id := nvl(l_parameters(1),178);
2406   l_responsibility_id := l_parameters(2);
2407   l_security_group_id := l_parameters(3);
2408   l_function_id := l_parameters(4);
2409 
2410   if P is null
2411   then
2412     l_text := null;
2413   else
2414     l_text := icx_call.decrypt2(P,l_session_id);
2415   end if;
2416 
2417   -- 2802333 nlbarlow
2418   l_url := icx_portlet.createExecLink(p_application_id => l_resp_appl_id,
2419                        p_responsibility_id => l_responsibility_id,
2420                        p_security_group_id => l_security_group_id,
2421                        p_function_id => l_function_id,
2422                        p_parameters => l_text,
2423                        p_url_only => 'Y');
2424 
2425   owa_util.mime_header('text/html', FALSE);
2426 
2427   owa_util.redirect_url(l_url);
2428 
2429   owa_util.http_header_close;
2430 
2431 /*
2432   if l_text = '-1' then
2433     raise e_session_invalid;
2434   end if;
2435 
2436   if l_function_id is null
2437   then
2438      l_function_type := '';
2439   else
2440     select TYPE
2441     into   l_function_type
2442     from   FND_FORM_FUNCTIONS
2443     where  FUNCTION_ID = l_function_id;
2444   end if;
2445   l_menu_id := l_parameters(5);
2446 
2447 
2448   --mputman moved to after multiorg code
2449   --  l_validate := icx_sec.validateSessionPrivate(c_session_id => l_session_id,
2450   --                           c_resp_appl_id => l_resp_appl_id,
2451   --                           c_security_group_id => l_security_group_id,
2452   --                           c_responsibility_id => l_responsibility_id,
2453   --                           c_function_id => l_function_id,
2454   --                           c_update => FALSE);
2455 
2456   select multi_org_flag
2457   into   l_multi_org_flag
2458   from   fnd_product_groups
2459   where  rownum < 2;
2460 
2461   if l_multi_org_flag = 'Y'
2462   then
2463       fnd_profile.get_specific(
2464           name_z                  => 'ORG_ID',
2465           responsibility_id_z     => l_responsibility_id,
2466           application_id_z        => l_resp_appl_id,
2467           val_z                   => l_org_id,
2468           defined_z               => l_profile_defined);
2469   end if;
2470 
2471   update ICX_SESSIONS
2472   set 	 RESPONSIBILITY_APPLICATION_ID = l_resp_appl_id,
2473          RESPONSIBILITY_ID = l_responsibility_id,
2474          SECURITY_GROUP_ID = l_security_group_id,
2475          ORG_ID = l_org_id,
2476          FUNCTION_ID = l_function_id,
2477          FUNCTION_TYPE = l_function_type,
2478          MENU_ID = l_menu_id
2479   where	SESSION_ID = l_session_id;
2480 
2481   commit;
2482 
2483   l_validate := icx_sec.validateSessionPrivate(c_session_id => l_session_id,
2484                            c_resp_appl_id => l_resp_appl_id,
2485                            c_security_group_id => l_security_group_id,
2486                            c_responsibility_id => l_responsibility_id,
2487                            c_function_id => l_function_id,
2488                            c_update => FALSE);
2489 
2490   fnd_signon.audit_web_responsibility(icx_sec.g_login_id,
2491                                      l_responsibility_id,
2492                                      l_resp_appl_id,
2493                                      l_responsibility_id); -- mputman added for 1941776
2494 
2495   IF l_validate THEN
2496 
2497   -- nlbarlow 1574527
2498   icx_sec.g_validateSession_flag := false;
2499 
2500   runFunction(l_function_id,l_session_id,l_text,
2501               l_resp_appl_id,l_responsibility_id,l_security_group_id,
2502               l_menu_id,l_function_type,icx_sec.g_page_id);
2503 
2504   icx_sec.g_validateSession_flag := true;
2505   END IF;
2506 */
2507 
2508 exception
2509   when others then
2510     icx_sec.g_validateSession_flag := true;
2511     --htp.p(SQLERRM);
2512        htp.p(dbms_utility.format_error_stack);
2513 end;
2514 
2515 --  ***********************************************
2516 --     procedure runFunction
2517 --  ***********************************************
2518 procedure runFunction(c_function_id       in number,
2519 		                n_session_id        in number,
2520                       c_parameters        in VARCHAR2,
2521                       p_resp_appl_id      in NUMBER,
2522                       p_responsibility_id in NUMBER,
2523                       p_security_group_id in NUMBER,
2524                       p_menu_id           in NUMBER,
2525                       p_function_type     in VARCHAR2,
2526                       p_page_id           in NUMBER) is
2527 
2528      f				fnd_form_functions%rowtype;
2529      c_procedure_call		varchar2(2000);
2530      c_anchor			varchar2(2000);
2531      l_dbc                      varchar2(240);
2532      l_message                  varchar2(240);
2533      l_web_html_call            varchar2(240);
2534      l_parameters		varchar2(2000);
2535      l_table_count		number;
2536      l_names			l_v80_table;
2537      l_values			l_v2000_table;
2538      l_responsibility_id	number;
2539      l_profile_defined		boolean;
2540      l_resp_web_host		varchar2(2000) := NULL;
2541      l_resp_web_agent		varchar2(2000) := NULL;
2542      l_oa_html                  varchar2(30);
2543      c_call			integer;
2544      c_dummy			integer;
2545      l_package			varchar2(100);
2546      v_dot_location		number;
2547      v_count			number := 0;
2548      c_error_msg		varchar2(80);
2549      c_login_msg		varchar2(80);
2550      l_encrypted_session_id	varchar2(240);
2551      l_encrypted_transaction_id	varchar2(240);
2552      index1 number;
2553      index2 number;
2554      l_resp_appl_id NUMBER;
2555 
2556      cursor procFind(p_name varchar2) is
2557         SELECT 'exists'
2558         FROM   FND_ENABLED_PLSQL
2559         WHERE  PLSQL_TYPE = 'PROCEDURE'
2560         AND    PLSQL_NAME = p_name
2561         AND    ENABLED = 'Y';
2562 
2563      cursor packFind(p_pack varchar2, p_proc varchar2) is
2564         SELECT 'exists'
2565         FROM   FND_ENABLED_PLSQL
2566         WHERE  (PLSQL_TYPE = 'PACKAGE' AND PLSQL_NAME = p_pack
2567         OR     PLSQL_TYPE = 'PACKAGE.PROCEDURE' AND PLSQL_NAME = p_proc)
2568         AND    ENABLED = 'Y';
2569 
2570 begin
2571 
2572 select * into f
2573 from	fnd_form_functions
2574 where	function_id = c_function_id;
2575 
2576 /* bug 1142377, f.PARAMETERS may contain spaces.
2577 if f.PARAMETERS is not null and c_parameters is null
2578 then
2579   l_parameters := replace(f.PARAMETERS,' ','&');
2580 elsif f.PARAMETERS is not null and c_parameters is not null
2581 then
2582   l_parameters := replace(f.PARAMETERS,' ','&')||'&'||replace(c_parameters,' ','
2583 &');
2584 elsif f.PARAMETERS is null and c_parameters is not null
2585 then
2586   l_parameters := replace(c_parameters,' ','&');
2587 else
2588   l_parameters := '';
2589 end if;
2590 */
2591 
2592 if f.PARAMETERS is not null
2593 then
2594   if instrb(f.PARAMETERS,'&') > 0
2595   then
2596     l_parameters := f.PARAMETERS;
2597   else
2598     l_parameters := replace(f.PARAMETERS,' ','&');
2599   end if;
2600 end if;
2601 
2602 if l_parameters is not null and c_parameters is not null
2603 then
2604   l_parameters := l_parameters||'&';
2605 end if;
2606 
2607 if c_parameters is not null
2608 then
2609   if instrb(c_parameters,'&') > 0
2610   then
2611     l_parameters := l_parameters||c_parameters;
2612   else
2613     l_parameters := l_parameters||replace(c_parameters,' ','&');
2614   end if;
2615 end if;
2616 
2617 -- 1790825, support [MENU_ID]
2618 
2619 l_parameters :=  replace(l_parameters,'[MENU_ID]',icx_sec.g_menu_id);
2620 
2621 c_anchor := '';
2622 
2623 if f.type not in ('SERVLET','JSP', 'INTEROPJSP')
2624 then
2625 
2626   select responsibility_id, RESPONSIBILITY_APPLICATION_ID
2627   into   l_responsibility_id, l_resp_appl_id
2628   from   icx_sessions
2629   where  session_id = n_session_id;
2630 
2631 
2632   if ((l_responsibility_id is not NULL) AND (l_resp_appl_id is not null))
2633   then
2634     select	web_host_name, web_agent_name
2635     into	l_resp_web_host, l_resp_web_agent
2636     from	fnd_responsibility
2637     where	responsibility_id = nvl(p_responsibility_id,l_responsibility_id) -- Bug 2726022
2638     and         application_id = nvl(p_resp_appl_id,l_resp_appl_id); -- Bug 2160456
2639   else
2640     l_resp_web_host := '';
2641     l_resp_web_agent := '';
2642   end if;
2643 
2644   if f.web_host_name is not null
2645   then
2646    if (instr(f.web_host_name, '://') = 0) then
2647       c_anchor := FND_WEB_CONFIG.PROTOCOL||'//'||f.web_host_name;
2648    else
2649       c_anchor := f.web_host_name;
2650    end if;
2651   elsif l_resp_web_host is not null
2652   then
2653    if (instr(l_resp_web_host, '://') = 0) then
2654     c_anchor := FND_WEB_CONFIG.PROTOCOL||'//'||l_resp_web_host;
2655    else
2656       c_anchor := l_resp_web_host;
2657    end if;
2658   end if;
2659 
2660   if f.web_agent_name is not null
2661   then
2662     c_anchor := c_anchor||'/'||f.web_agent_name;
2663   elsif l_resp_web_agent is not null
2664   then
2665     c_anchor := c_anchor||'/'||l_resp_web_agent;
2666   end if;
2667 
2668 end if; -- not in ('SERVLET','JSP')
2669 
2670 /* Supposed to support MSOB
2671 if c_anchor is null
2672 then
2673         fnd_profile.get_specific(
2674                 name_z                  => 'APPS_WEB_AGENT',
2675                 responsibility_id_z     => l_responsibility_id,
2676                 val_z                   => c_anchor,
2677                 defined_z               => l_profile_defined);
2678 
2679 	if not l_profile_defined
2680 	then
2681 	    c_anchor := '';
2682 	end if;
2683 end if;
2684 */
2685 
2686 if c_anchor is not null
2687 then
2688    if f.web_html_call is not null
2689    then
2690        c_anchor := c_anchor||'/'||f.web_html_call;
2691    end if;
2692 
2693    if l_parameters is not null
2694    then
2695        c_anchor := c_anchor||'?';
2696        if f.web_ENCRYPT_PARAMETERS = 'Y'
2697        then
2698            unpackParameters(l_parameters,l_names,l_values);
2699            l_table_count := l_names.COUNT;
2700    	   for i in 1..l_table_count loop
2701                if i > 1
2702                then
2703                    c_anchor := c_anchor||',';
2704                end if;
2705 	       c_anchor := c_anchor||l_names(i)||'='||icx_call.encrypt2(l_values(i), n_session_id);
2706 	   end loop;
2707       else
2708             c_anchor := c_anchor||l_parameters;
2709       end if;
2710    end if;
2711 
2712    owa_util.redirect_url(c_anchor);
2713 
2714 elsif f.type = 'SERVLET' then
2715 
2716    l_encrypted_session_id := icx_call.encrypt3(n_session_id);
2717 
2718    fnd_profile.get(name => 'APPS_SERVLET_AGENT',
2719                     val => c_anchor);
2720 
2721    c_anchor := FND_WEB_CONFIG.trail_slash(c_anchor)||f.WEB_HTML_CALL||
2722                '?dbc='||FND_WEB_CONFIG.DATABASE_ID||
2723                '&'||'sessionid='||l_encrypted_session_id;
2724 
2725    if l_parameters is not null then
2726       c_anchor := c_anchor || '&' || l_parameters;
2727    end if;
2728 
2729    owa_util.redirect_url(c_anchor);
2730 
2731 elsif f.type = 'JSP' or f.type = 'INTEROPJSP' then
2732 
2733    l_encrypted_session_id := icx_call.encrypt3(n_session_id);
2734 
2735    l_web_html_call := replace(f.WEB_HTML_CALL,'apps.jsp','OA.jsp');
2736 
2737    if (instr(l_web_html_call,'OA.jsp') > 0)
2738    then
2739      fnd_profile.get(name => 'APPS_FRAMEWORK_AGENT',
2740                      val => c_anchor);
2741      l_message := 'Applications Framework Agent';
2742    else
2743      fnd_profile.get(name => 'APPS_SERVLET_AGENT',
2744                      val => c_anchor);
2745      l_message := 'Applications Servlet Agent';
2746    end if;
2747 
2748    if(c_anchor is null) then
2749       htp.p(l_message||' not set, contact Administrator');
2750    else
2751      c_anchor := FND_WEB_CONFIG.TRAIL_SLASH(c_anchor);
2752 
2753      index1 := INSTRB(c_anchor, '//', 1) + 2;      /* skip 'http://' */
2754 
2755      index2 := INSTRB(c_anchor, '/', index1);  /* get to 'http://serv:port/' */
2756 
2757      if(index1 <> index2) AND (index1 <> 2) AND (index2 > 2)
2758            AND (index1 is not NULL) AND (index2 is not NULL) then
2759          c_anchor := FND_WEB_CONFIG.TRAIL_SLASH(SUBSTRB(c_anchor, 1, index2-1));
2760      else
2761          htp.p('Invalid '||l_message||', contact Administrator');
2762          c_anchor := '';
2763      end if;
2764 
2765      l_encrypted_transaction_id :=
2766        icx_call.encrypt3(icx_sec.createTransaction(
2767          n_session_id,p_resp_appl_id,p_responsibility_id,p_security_group_id,
2768          p_menu_id,c_function_id,p_function_type,p_page_id));
2769 
2770      c_anchor := FND_WEB_CONFIG.trail_slash(c_anchor)||
2771                  FND_WEB_CONFIG.trail_slash(icx_sec.g_OA_HTML)||
2772                  l_web_html_call;
2773 
2774      fnd_profile.get(name => 'APPS_DATABASE_ID',
2775                      val => l_dbc);
2776 
2777      if l_dbc is null
2778      then
2779        l_dbc := FND_WEB_CONFIG.DATABASE_ID;
2780      end if;
2781 
2782      if (instr(l_web_html_call,'?') > 0)
2783      then
2784        c_anchor := c_anchor||'&'||'dbc='||l_dbc;
2785      else
2786        c_anchor := c_anchor||'?dbc='||l_dbc;
2787      end if;
2788 
2789      c_anchor := c_anchor||'&'||'language_code='||icx_sec.g_language_code||
2790                  '&'||'transactionid='||l_encrypted_transaction_id;
2791 
2792      if (instr(c_anchor,'OA.jsp') = 0)
2793      then -- Other jsps still require sessionid
2794        c_anchor := c_anchor||'&'||'sessionid='||l_encrypted_session_id;
2795      end if;
2796 
2797      if l_parameters is not null then
2798         c_anchor := c_anchor || '&' || l_parameters;
2799      end if;
2800    end if;
2801 
2802    if c_anchor is not null
2803    then
2804       owa_util.redirect_url(c_anchor);
2805    end if;
2806 
2807 else
2808    -- ********************
2809    -- c_anchor is null
2810    -- ********************
2811 
2812    c_procedure_call := upper(f.web_html_call);
2813 
2814    v_dot_location := instr(c_procedure_call, '.');
2815    if (v_dot_location = 0) then
2816       --no period so this is a procedure
2817       for prec in procFind(c_procedure_call) loop
2818           v_count := v_count + 1;
2819       end loop;
2820    else
2821       -- this is a package.procedure
2822       -- check if either the package is enabled or the package.procedure
2823       l_package := substr(c_procedure_call, 0, v_dot_location-1);
2824       for prec in packFind(l_package, c_procedure_call) loop
2825           v_count := v_count + 1;
2826       end loop;
2827    end if;
2828 
2829    if (v_count > 0)
2830    then
2831 
2832       if l_parameters is not null
2833       then
2834          unpackParameters(l_parameters,l_names,l_values);
2835          c_procedure_call := c_procedure_call||'(';
2836          l_table_count := l_names.COUNT;
2837          for i in 1..l_table_count loop
2838             if i > 1
2839 	    then
2840 	       c_procedure_call := c_procedure_call||',';
2841 	    end if;
2842             if f.web_ENCRYPT_PARAMETERS = 'Y'
2843             then
2844                c_procedure_call := c_procedure_call||l_names(i)||' => '||icx_call.encrypt2(l_values(i), n_session_id);
2845             else
2846                c_procedure_call := c_procedure_call||l_names(i)||' => '''||l_values(i)||'''';
2847             end if;
2848          end loop;
2849          c_procedure_call := c_procedure_call||')';
2850       end if;
2851 
2852       c_call := dbms_sql.open_cursor;
2853       dbms_sql.parse(c_call,'begin '||c_procedure_call||'; end;',dbms_sql.native);
2854       c_dummy := dbms_sql.execute(c_call);
2855       dbms_sql.close_cursor(c_call);
2856 
2857    else
2858       fnd_message.set_name('ICX','ICX_INVALID_FUNCTION');
2859       c_error_msg := fnd_message.get;
2860       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
2861       c_login_msg := fnd_message.get;
2862 
2863       OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
2864 
2865    end if;
2866 
2867 end if;
2868 
2869 end;
2870 
2871 --  ***********************************************
2872 --     procedure unpackParameters
2873 --  ***********************************************
2874 
2875 procedure unpackParameters(p_parameters in varchar2,
2876                            p_names      out nocopy l_v80_table,
2877                            p_values     out nocopy l_v2000_table) is
2878 Y               varchar2(4000);
2879 l_length        number(15);
2880 c_param         number(15);
2881 c_count         number(15);
2882 c_char          varchar2(30);
2883 c_word          varchar2(2000);
2884 c_value         number(15);
2885 
2886 begin
2887 
2888 Y := p_parameters||'&]';
2889 l_length := length(Y)-1;
2890 c_param := 1;
2891 c_count := 0;
2892 c_char := '';
2893 c_word := '';
2894 
2895 while c_count <= l_length loop
2896         if c_char = '=' or c_char = '&'
2897         then
2898                 if c_char = '='
2899                 then
2900                         p_names(c_param) := c_word;
2901                 else
2902                         p_values(c_param) := c_word;
2903                         c_param := c_param + 1;
2904                 end if;
2905                 c_count := c_count + 1;
2906                 c_char := substr(Y,c_count,1);
2907                 c_word := '';
2908         else
2909                 c_word := c_word||c_char;
2910                 c_count := c_count + 1;
2911                 c_char := substr(Y,c_count,1);
2912         end if;
2913 end loop;
2914 
2915 end;
2916 
2917 --  ***********************************************
2918 --     procedure unpackParameters
2919 --  ***********************************************
2920 
2921 procedure unpackParameters(p_parameters in varchar2,
2922                            p_names      out nocopy l_v80_table,
2923                            p_values     out nocopy l_v240_table) is
2924 Y 		varchar2(2000);
2925 l_length	number(15);
2926 c_param         number(15);
2927 c_count         number(15);
2928 c_char          varchar2(30);
2929 c_word          varchar2(240);
2930 c_value		number(15);
2931 
2932 begin
2933 
2934 Y := p_parameters||'&]';
2935 l_length := length(Y)-1;
2936 c_param := 1;
2937 c_count := 0;
2938 c_char := '';
2939 c_word := '';
2940 
2941 while c_count <= l_length loop
2942         if c_char = '=' or c_char = '&'
2943         then
2944 		if c_char = '='
2945 		then
2946 			p_names(c_param) := c_word;
2947 		else
2948                 	p_values(c_param) := c_word;
2949                 	c_param := c_param + 1;
2950 		end if;
2951                 c_count := c_count + 1;
2952                 c_char := substr(Y,c_count,1);
2953                 c_word := '';
2954 	else
2955                 c_word := c_word||c_char;
2956                 c_count := c_count + 1;
2957                 c_char := substr(Y,c_count,1);
2958         end if;
2959 end loop;
2960 
2961 end;
2962 
2963 --  ***********************************************
2964 --     function getFunctions
2965 --  ***********************************************
2966 function getFunctions
2967 	return varchar2 is
2968 
2969 	c_user_id		number;
2970 	c_responsibility_id 	number;
2971 	c_anchor		varchar2(2000);
2972 	c_error_msg		varchar2(2000);
2973 	c_login_msg		varchar2(2000);
2974 	c_known_as		varchar2(80);
2975 	c_string		varchar2(10000);
2976 	n_session_id		number;
2977 
2978 	cursor resps is
2979 		select	a.responsibility_id,a.responsibility_name,
2980 		web_HOST_NAME,web_AGENT_NAME
2981 	from  	fnd_responsibility_vl a,
2982 		FND_USER_RESP_GROUPS b,
2983 		icx_sessions c
2984 	where   n_session_id = c.session_id
2985 	and	c.user_id = b.user_id
2986         and     a.version = 'W'
2987         and     a.start_date <= sysdate
2988         and     (a.end_date is null or a.end_date > sysdate)
2989         and     b.start_date <= sysdate
2990         and     (b.end_date is null or b.end_date > sysdate)
2991 	order by responsibility_name;
2992 
2993 	cursor functions is
2994         	select	user_function_name,description,
2995 			web_HOST_NAME,web_AGENT_NAME,web_HTML_CALL,
2996 			PARAMETERS
2997         	from	fnd_form_functions_vl c,
2998 			fnd_resp_functions a
2999         	where	c_responsibility_id = a.responsibility_id
3000 		and	a.action_id = c.function_id
3001 		order by user_function_name;
3002 
3003 begin
3004 
3005    /*** Get the cookie for this session.
3006 	and find out other information from the db
3007     ***/
3008 
3009  n_session_id := icx_sec.getsessioncookie;
3010 
3011  if (n_session_id <= 0)
3012  then
3013       fnd_message.set_name('FND','FND_SESSION_ICX_EXPIRED');
3014       c_error_msg := fnd_message.get;
3015       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
3016       c_login_msg := fnd_message.get;
3017 
3018       OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
3019  else
3020    c_string := '';
3021    for i in Resps loop
3022         c_responsibility_id := i.responsibility_id;
3023 
3024 	c_anchor := '';
3025 	for r in functions loop
3026 
3027         c_anchor := r.web_html_call;
3028 
3029         if r.web_agent_name is not null
3030         then
3031                 c_anchor := '/'||r.web_agent_name||'/'||c_anchor;
3032         end if;
3033 
3034         if r.web_host_name is not null
3035         then
3036 	   if (instr(r.web_host_name, '://') = 0) then
3037 	      c_anchor := FND_WEB_CONFIG.PROTOCOL||'//'||r.web_host_name||'/';
3038 	   else
3039 	      c_anchor := r.web_host_name||'/';
3040 	   end if;
3041 
3042                 c_anchor := FND_WEB_CONFIG.PROTOCOL||'//'||r.web_host_name||c_anchor;
3043         end if;
3044 
3045 	if r.PARAMETERS is not null
3046 	then
3047 	    c_anchor := c_anchor||'?'||r.PARAMETERS;
3048 	end if;
3049 
3050 	  c_string := c_string||'nav_win.document.write('''||htf.anchor(c_anchor,r.user_function_name,'','TARGET=mainWindow.location')||''');'||htf.nl;
3051 
3052 	end loop;
3053    end loop;
3054  end if;
3055 return c_string;
3056 
3057 end;
3058 
3059 procedure displayWebUser is
3060 
3061 l_title			varchar2(80);
3062 l_helpmsg		varchar2(240);
3063 l_helptitle		varchar2(240);
3064 l_actions		icx_cabo.actionTable;
3065 l_toolbar		icx_cabo.toolbar;
3066 username		varchar2(30);
3067 c_error_msg		varchar2(2000);
3068 c_login_msg		varchar2(2000);
3069 l_agent                 varchar2(240);
3070 l_dbhost                varchar2(240);
3071 l_tabicons              icx_cabo.tabiconTable;
3072 l_prompts icx_util.g_prompts_table;--mputman added 1402459
3073 
3074 BEGIN
3075 
3076    icx_util.getprompts(601, 'ICX_OBIS_TOOLBAR', l_title, l_prompts); --mputman added for bug 1402459
3077   -- Check session and current user
3078   wfa_sec.GetSession(username);
3079   username := upper(username);
3080 
3081     htp.headopen;
3082     htp.p('<SCRIPT>');
3083 
3084     icx_admin_sig.help_win_script('GENPREF', null, 'FND');
3085 
3086     htp.p('</SCRIPT>');
3087     htp.headclose;
3088 
3089   l_toolbar.title := wf_core.translate('ICX_PREFERENCES');
3090   l_toolbar.help_url := 'javascript:top.help_window()';
3091   fnd_message.set_name('ICX','ICX_HELP');
3092   l_toolbar.help_mouseover := FND_MESSAGE.GET;
3093 
3094   l_toolbar.menu_url :=owa_util.get_cgi_env('SCRIPT_NAME')||'/OracleNavigate.Responsibility'; --mputman added for bug 1402459
3095   l_toolbar.menu_mouseover := l_prompts(7); -- from region ICX_OBIS_TOOLBAR mputman added for bug 1402459
3096 
3097   IF (icx_sec.g_mode_code <> 'SLAVE') THEN
3098   --mputman isolated menubutton to exclude slave mode 1747045
3099   l_toolbar.custom_option1_url := icx_plug_utilities.getPLSQLagent ||
3100                                   'OracleMyPage.Home';
3101   l_toolbar.custom_option1_mouseover := wf_core.translate('RETURN_TO_HOME');
3102   l_toolbar.custom_option1_gif := '/OA_MEDIA/FNDHOME.gif';
3103   l_toolbar.custom_option1_mouseover_gif := '/OA_MEDIA/FNDHOME.gif';
3104   END IF;
3105 
3106   l_helpmsg := wf_core.translate('ICX_PREF_DESC');
3107   --l_helpmsg := '';
3108   l_helptitle := wf_core.translate('ICX_PREFERENCES');
3109 
3110   icx_cabo.container(p_toolbar => l_toolbar,
3111                      p_helpmsg => l_helpmsg,
3112                      p_helptitle => l_helptitle,
3113                      p_url => owa_util.get_cgi_env('SCRIPT_NAME')||'/oracleapps.displayWebUserlocal?p_message_flag=N',
3114                      p_action => TRUE);
3115 
3116 exception
3117    when others then
3118       fnd_message.set_name('ICX','ICX_SESSION_FAILED');
3119       c_error_msg := fnd_message.get;
3120       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
3121       c_login_msg := fnd_message.get;
3122 
3123       OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
3124 end;
3125 
3126 
3127 --  ***********************************************
3128 --     Procedure displayWebUserlocal
3129 --  ***********************************************
3130 procedure displayWebUserlocal(p_message_flag VARCHAR2) is
3131 
3132 u			fnd_user%rowtype;
3133 c_user_id 		varchar2(15);
3134 c_lang_code		varchar2(30);
3135 c_language_code		varchar2(30);
3136 c_title 		varchar2(80);
3137 c_prompts		icx_util.g_prompts_table;
3138 l_message		varchar2(2000);
3139 l_pwlen                 number;
3140 c_error_msg		varchar2(2000);
3141 c_login_msg		varchar2(2000);
3142 c_nls_lang		varchar2(30);
3143 c_iso_lang		varchar2(10);
3144 c_iso_terr		varchar2(10);
3145 l_date_format		varchar2(100);
3146 l_mail_pref             varchar2(20);
3147 l_curr_mail_pref         varchar2(20);
3148 c_description		varchar2(255);
3149 c_browser                varchar2(400):= owa_util.get_cgi_env('HTTP_USER_AGENT');
3150 l_lookup_codes		icx_util.g_lookup_code_table;
3151 l_lookup_meanings	icx_util.g_lookup_meaning_table;
3152 l_enc_lookup_codes		icx_util.g_lookup_code_table;
3153 l_enc_lookup_meanings	icx_util.g_lookup_meaning_table;
3154 l_numeric_lookup_codes		icx_util.g_lookup_code_table;
3155 l_numeric_lookup_meanings	icx_util.g_lookup_meaning_table;
3156 username                varchar2(30);
3157 dm_node_id              number;
3158 dm_node_name            varchar2(240);
3159 l_actions               icx_cabo.actionTable;
3160 l_actiontext            varchar2(2000);
3161 l_numeric_characters    varchar2(30);
3162 l_territory             varchar2(30);
3163 l_timezone              NUMBER;
3164 l_timezone_code         VARCHAR2(200);
3165 l_encoding              VARCHAR2(200);
3166 l_profile_defined       boolean;
3167 l_auth_mode             VARCHAR2(50);
3168 l_tz_enabled            VARCHAR2(10);
3169 l_counter               NUMBER;
3170    TYPE t_node_id IS TABLE OF fnd_dm_nodes.node_id%TYPE;
3171    TYPE t_node_name IS TABLE OF fnd_dm_nodes.node_name%TYPE;
3172    v_node_id t_node_id;
3173    v_node_name t_node_name;
3174 
3175 
3176   cursor get_lang is
3177         SELECT LANGUAGE_CODE,
3178                NLS_LANGUAGE,
3179                DESCRIPTION,
3180                ISO_LANGUAGE,
3181                ISO_TERRITORY
3182         FROM   FND_LANGUAGES_VL
3183         WHERE  INSTALLED_FLAG in ('I', 'B')
3184         ORDER BY DESCRIPTION;
3185 
3186   cursor get_mail is
3187         select NAME, TEXT
3188         from WF_RESOURCES
3189         where TYPE = 'WFTKN'
3190         and NAME LIKE 'WFPREF_MAILP%'
3191         and LANGUAGE = userenv('LANG')
3192         ORDER BY NAME;
3193 
3194   CURSOR get_dm is
3195    SELECT  node_id, node_name
3196    FROM   fnd_dm_nodes
3197    ORDER  BY node_name;
3198 
3199   cursor get_territory is
3200      select t.territory_short_name territory_name,
3201 	    t.nls_territory
3202      from   fnd_territories_vl t,
3203 	    v$nls_valid_values v
3204      where t.nls_territory = v.value
3205      and   v.parameter = 'TERRITORY'
3206      order by t.territory_short_name;
3207 
3208      CURSOR get_tz IS
3209      SELECT '(GMT ' ||
3210        rtrim(tz_offset(timezone_code),chr(0))
3211       || ') ' || name DISPLAYED_NAME
3212        , upgrade_tz_id PROFILE_VALUE
3213      FROM FND_TIMEZONES_VL
3214      WHERE enabled_flag = 'Y'
3215      ORDER BY gmt_offset, name;
3216 
3217 
3218 begin
3219 
3220   if (icx_sec.validateSession) then
3221 
3222      select  * into u
3223      from    fnd_user
3224      where   user_id = icx_sec.g_user_id;
3225 
3226      c_language_code     := icx_sec.g_language_code;
3227      l_date_format       := icx_sec.g_date_format;
3228      l_date_format       := replace(upper(l_date_format), 'YYYY', 'RRRR');
3229      l_date_format       := replace(l_date_format, 'YY', 'RRRR');
3230      l_territory         := icx_sec.g_nls_territory;
3231      l_numeric_characters := icx_sec.g_numeric_characters;
3232 
3233      --get profile value for CLIENT_TIMEZONE_ID
3234      --decode into displayed_name
3235         fnd_profile.get_specific(
3236                 name_z                  => 'CLIENT_TIMEZONE_ID',
3237                 user_id_z               => icx_sec.g_user_id,
3238                 val_z                   => l_timezone,
3239                 defined_z               => l_profile_defined);
3240 
3241         fnd_profile.get_specific(
3242                 name_z                  => 'FND_NATIVE_CLIENT_ENCODING',
3243                 user_id_z               => icx_sec.g_user_id,
3244                 val_z                   => l_encoding,
3245                 defined_z               => l_profile_defined);
3246 
3247 
3248         fnd_profile.get_specific(
3249                 name_z                  => 'ENABLE_TIMEZONE_CONVERSIONS',
3250                 user_id_z               => icx_sec.g_user_id,
3251                 val_z                   => l_tz_enabled,
3252                 defined_z               => l_profile_defined);
3253 
3254         BEGIN
3255           SELECT 'LDAP'
3256           INTO l_auth_mode
3257           FROM fnd_user
3258           WHERE user_id = icx_sec.g_user_id
3259           AND upper(encrypted_user_password)='EXTERNAL';
3260 
3261           EXCEPTION
3262            WHEN no_data_found THEN
3263            l_auth_mode :='FND';
3264         END;
3265 
3266          --toggle this off if not using timezones
3267          IF l_tz_enabled = 'Y' THEN
3268 
3269         BEGIN
3270             SELECT '(GMT ' ||
3271               rtrim(tz_offset(timezone_code),chr(0))
3272              || ') ' || name DISPLAYED_NAME
3273             INTO
3274               l_timezone_code
3275             FROM FND_TIMEZONES_VL
3276             WHERE enabled_flag = 'Y'
3277             AND upgrade_tz_id=l_timezone;
3278             EXCEPTION WHEN no_data_found THEN
3279             NULL;--what do we do here?
3280         END;
3281      -- timezone
3282          END IF;
3283 
3284 
3285      if (instr(l_date_format, 'RR') > 0) then
3286 	 if (instr(l_date_format, 'RRRR')  = 0) then
3287 	     l_date_format := replace(l_date_format, 'RR', 'RRRR');
3288 	 end if;
3289      end if;
3290      icx_util.getLookups('ICX_DATE_FORMATS',l_lookup_codes,l_lookup_meanings);
3291      icx_util.getLookups('FND_CLIENT_CHARACTER_SETS',l_enc_lookup_codes,l_enc_lookup_meanings);
3292      icx_util.getLookups('ICX_NUMERIC_CHARACTERS',l_numeric_lookup_codes,l_numeric_lookup_meanings);
3293 
3294      -- Check session and current user
3295      wfa_sec.GetSession(username);
3296      username := upper(username);
3297      l_curr_mail_pref := wf_pref.get_pref (username, 'MAILTYPE');
3298      -- get the document management home node information
3299      fnd_document_management.get_dm_home (username, dm_node_id, dm_node_name);
3300 
3301      htp.htmlOpen;
3302      htp.headOpen;
3303      icx_util.copyright;
3304 
3305 
3306      htp.p('<SCRIPT LANGUAGE="JavaScript">');
3307      htp.p('<!-- Hide from old Browsers');
3308      icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpmp.htm');
3309 
3310      IF icx_sec.g_mode_code = 'SLAVE' THEN
3311         --mputman added to close window when in slave mode 1747045
3312         htp.p('function cancelpref() {
3313               parent.window.name="";
3314                parent.window.close();
3315               }');
3316      else
3317      if icx_sec.g_mode_code in ( '115J', '115P', '115X') then
3318         htp.p('function cancelpref() {
3319                top.location.href = "'||owa_util.get_cgi_env('SCRIPT_NAME')||'/OracleNavigate.Responsibility";
3320               }'); -- mputman changed for bug 1402459
3321 
3322      else
3323         htp.p('function cancelpref() {
3324               top.location.href = "'||wfa_html.base_url ||'/OracleNavigate.Responsibility";
3325         }');
3326      end if;
3327      END IF;
3328 
3329      htp.p('function savepref() {
3330      var l_alert = false');
3331 
3332      l_pwlen := to_number(nvl(Fnd_Profile.Value('SIGNON_PASSWORD_LENGTH'), 5));
3333      fnd_message.set_name('FND','PASSWORD-LONGER');
3334      fnd_message.set_token('LENGTH',to_char(l_pwlen));
3335      l_message := icx_util.replace_quotes(fnd_message.get);
3336      htp.p('    var lpwd = document.userpref.i_5.value;
3337              if (lpwd.length <  '||to_char(l_pwlen)||' '||'&'||'&'||' document.userpref.i_4.value != "") {
3338                 alert('''||l_message||''');
3339                 document.userpref.i_5.focus();
3340                 l_alert = true
3341                 };');
3342 
3343      fnd_message.set_name('ICX','ICX_REQU_REPAS');
3344      l_message := icx_util.replace_quotes(fnd_message.get);
3345      htp.p('    if ((document.userpref.i_5.value != document.userpref.i_6.value)||(document.userpref.i_4.value == "" '||'&'||'&'||' document.userpref.i_5.value !="")) {
3346         alert('''||l_message||''');
3347         document.userpref.i_6.focus();
3348                 l_alert = true
3349                 };');
3350 
3351      htp.p('    if (l_alert==false) {
3352                    document.userpref.submit()
3353              };
3354 	}');
3355 
3356 
3357      htp.p('// -->');
3358      htp.p('</SCRIPT>');
3359      htp.headClose;
3360 
3361      htp.p('<BODY bgcolor="#CCCCCC">');
3362      icx_util.getPrompts(601,'ICX_PREFERENCE',c_title,c_prompts);
3363 
3364      /* use Oracle logo */
3365 --   icx_admin_sig.toolbar(language_code => c_language_code);
3366 --   htp.title(c_title);
3367 --   htp.p('<H2>'||c_title||'</H2>');
3368 
3369      htp.br;
3370      htp.formOpen('OracleApps.UUI','POST','','','NAME="userpref"');
3371          htp.tableOpen(calign=>'CENTER');
3372              htp.tableRowOpen;                                -- Known As
3373 		 htp.tableData(c_prompts(1),'RIGHT');
3374 		 htp.tableData(htf.formText('i_1','40','50',icx_util.replace_alt_quotes(u.description))); -- added call to replcae quotes 2637147
3375    	     htp.tableRowClose;
3376 
3377 	     htp.tableRowOpen;                                -- Language
3378 		 htp.tableData(c_prompts(2),'RIGHT');
3379 		 htp.p('<TD ALGIN="LEFT">');
3380 		 htp.p('<SELECT NAME="i_2" SIZE="1">');
3381 		 for prec in get_lang loop
3382 		     if (prec.LANGUAGE_CODE = c_language_code) then
3383 			htp.p('<OPTION VALUE="' || prec.NLS_LANGUAGE ||
3384 				       '" SELECTED> ' || prec.description );
3385 		     else
3386 			htp.p('<OPTION VALUE="' || prec.NLS_LANGUAGE ||
3387 				       '"> ' || prec.description );
3388 		     end if;
3389 		 end loop;
3390 		 htp.p('</SELECT>');
3391 	         htp.p('</TD>');
3392              htp.tableRowClose;
3393     --toggle this off if not using timezones
3394          IF l_tz_enabled = 'Y' THEN
3395 
3396     --TZ
3397 	     htp.tableRowOpen;                                -- Timezone
3398 		 htp.tableData(c_prompts(11),'RIGHT');
3399 		 htp.p('<TD ALGIN="LEFT">');
3400 		 htp.p('<SELECT NAME="i_11" SIZE="1">');
3401 		 htp.p('<OPTION VALUE="''"> ');
3402        for tz in get_tz loop
3403           --need if tz%ROWCOUNT>0 then ... here
3404 		     if (tz.PROFILE_VALUE = l_timezone) then
3405 			htp.p('<OPTION VALUE="' || tz.PROFILE_VALUE ||
3406 				       '" SELECTED> ' || tz.DISPLAYED_NAME );
3407 		     else
3408 			htp.p('<OPTION VALUE="' || tz.PROFILE_VALUE ||
3409 				       '"> ' || tz.DISPLAYED_NAME );
3410 		     end if;
3411 		 end loop;
3412 		 htp.p('</SELECT>');
3413 	         htp.p('</TD>');
3414              htp.tableRowClose;
3415 
3416     --end TZ
3417     ELSE
3418 	     htp.formHidden('i_11',l_timezone);-- timezone hidden/disabled
3419 
3420          END IF;
3421            --FND CLIENT ENCODING
3422 	     htp.tableRowOpen;
3423 		 htp.tableData(c_prompts(12),'RIGHT');
3424 		 htp.p('<TD ALGIN="LEFT">');
3425 		 htp.p('<SELECT NAME="i_12" SIZE="1">');
3426 			htp.p('<OPTION VALUE="''"> ');
3427 
3428 		 for i in 1..l_enc_lookup_meanings.COUNT loop
3429 		     if (l_encoding = l_enc_lookup_codes(i)) then
3430 			htp.p('<OPTION VALUE="' || l_enc_lookup_codes(i) ||
3431 				       '" SELECTED> ' || l_enc_lookup_meanings(i) );
3432 		     else
3433 			htp.p('<OPTION VALUE="' || l_enc_lookup_codes(i) ||
3434 				       '"> ' || l_enc_lookup_meanings(i) );
3435 		     end if;
3436 		 end loop;
3437 		 htp.p('</SELECT>');
3438 	         htp.p('</TD>');
3439              htp.tableRowClose;
3440 
3441 
3442            --fce
3443 
3444 
3445              htp.tableRowOpen;                                -- date format
3446 		 htp.tableData(c_prompts(3),'RIGHT');
3447 		 fnd_message.set_name('ICX','ICX_RRRR');
3448 		 l_message := fnd_message.get;
3449 		 htp.p('<TD ALGIN="LEFT">');
3450 		 htp.formSelectOpen('i_3');
3451 		 for i in 1..l_lookup_meanings.COUNT loop
3452 		     if l_date_format = l_lookup_codes(i)
3453 		     then
3454 			 htp.formSelectOption(to_char(to_date('31/12/2000','DD/MM/RRRR'),l_lookup_codes(i)),'SELECTED','VALUE="'||l_lookup_codes(i)||'"');
3455 		     else
3456 			 htp.formSelectOption(to_char(to_date('31/12/2000','DD/MM/RRRR'),l_lookup_codes(i)),'','VALUE="'||l_lookup_codes(i)||'"');
3457 		     end if;
3458 		 end loop;
3459 		 htp.formSelectClose;
3460 		 htp.p('</TD>');
3461    	     htp.tableRowClose;
3462 
3463 	     htp.tableRowOpen;                          -- nls numeric characters
3464 		  htp.tableData(c_prompts(9), 'RIGHT');
3465 		  htp.p('<TD ALGIN="LEFT">');
3466 		  htp.p('<SELECT NAME="i_9" SIZE="1">');
3467                   -- change to use lookup for icx_numeric_characters
3468                   FOR i IN 1..l_numeric_lookup_meanings.count LOOP
3469                     /*
3470                     if l_numeric_characters = ',.'
3471                     then
3472                        htp.p('<OPTION VALUE=".,"> ' || '10,000.00' );
3473                        htp.p('<OPTION SELECTED VALUE=",."> ' || '10.000,00' );
3474                     else
3475    	                 htp.p('<OPTION SELECTED VALUE=".,"> ' || '10,000.00' );
3476    	                 htp.p('<OPTION VALUE=",."> ' || '10.000,00' );
3477                     end if;
3478                     */
3479 		              if (l_numeric_characters = l_numeric_lookup_codes(i)) then
3480 			              htp.p('<OPTION VALUE="' || l_numeric_lookup_codes(i) ||
3481 				                 '" SELECTED> ' || l_numeric_lookup_meanings(i) );
3482 		              else
3483 			              htp.p('<OPTION VALUE="' || l_numeric_lookup_codes(i) ||
3484 				                 '"> ' || l_numeric_lookup_meanings(i) );
3485 		              end if;
3486                   END LOOP;
3487 
3488 		  htp.p('</SELECT>');
3489 		  htp.p('</TD>');
3490 	     htp.tableRowClose;
3491 
3492 	     htp.tableRowOpen;                          -- nls territory
3493 		  htp.tableData(c_prompts(10), 'RIGHT');
3494 		  htp.p('<TD ALGIN="LEFT">');
3495 		  htp.p('<SELECT NAME="i_10" SIZE="1">');
3496 
3497 		  for trec in get_territory loop
3498 		    if (trec.nls_territory = l_territory) then
3499  		       htp.p('<OPTION VALUE="' || trec.nls_territory || '" SELECTED> ' || trec.territory_name);
3500 		    else
3501 		       htp.p('<OPTION VALUE="' || trec.nls_territory || '"> ' || trec.territory_name );
3502 	            end if;
3503 		  end loop;
3504 
3505 		  htp.p('</SELECT>');
3506 		  htp.p('</TD>');
3507 	     htp.tableRowClose;
3508 
3509              htp.tableRowOpen;                                -- Mail Preference
3510                  htp.tableData(wf_core.translate('WFPREF_SENDEMAIL_PROMPT'),'RIGHT');
3511 	         htp.p('<TD ALGIN="LEFT">');
3512                  htp.p('<SELECT NAME="i_7" SIZE="1">');
3513 
3514 	         /*
3515 	         ** The get_mail cursor is used to fetch the codes and display names
3516 	         ** used for the mail preference values.
3517 	         ** I've named the prompts for the mail options appropriately so
3518 	         ** they can be uniquely fetched in a list and dropped easily into
3519 	         ** a poplist.  The codes for mail preferences are
3520 	         ** MAILHTML, MAILATTH, MAILTEXT, etc. The corresponding prompts for
3521 	         ** these options are  WFPREF_MAILP1-MAILHTML, WFPREF_MAILP2-MAILATTH,
3522 	         ** WFPREF_MAILP3-MAILTEXT etc.  I drop  WFPREF_MAILP#- part and leave
3523 	         ** the code that we'll save in the database for this preference.
3524 	         ** The WFPREF_MAILP# portion allows me to sort these as I wish.
3525 	         */
3526 	         for mail in get_mail loop
3527 	             l_mail_pref := SUBSTR(mail.name, INSTR(mail.name, '-') + 1);
3528 
3529 	             if (l_mail_pref = l_curr_mail_pref) then
3530 		        htp.p('<OPTION VALUE="' || l_mail_pref || '" SELECTED> ' || mail.text);
3531 		     else
3532 		       htp.p('<OPTION VALUE="' || l_mail_pref ||'"> ' || mail.text );
3533 		     end if;
3534 	         end loop;
3535 
3536 	         htp.p('</SELECT>');
3537 	         htp.p('</TD>');
3538    	     htp.tableRowClose;
3539 
3540            ---------
3541       OPEN get_dm;
3542       FETCH get_dm bulk collect INTO v_node_id, v_node_name;
3543       CLOSE get_dm;
3544       IF v_node_id.count > 0  THEN
3545          htp.tableRowOpen;                                -- DM Home Preference
3546          htp.tableData(wf_core.translate('WFPREF_DMHOME_PROMPT'),'RIGHT');
3547          htp.p('<TD ALGIN="LEFT">');
3548          htp.p('<SELECT NAME="i_8" SIZE="1">');
3549          FOR counter IN 1..v_node_id.count LOOP
3550 
3551 
3552                if (v_node_id(counter) = dm_node_id) then
3553 
3554                 htp.p('<OPTION VALUE="' || v_node_id(counter) ||
3555                  '" SELECTED> ' || v_node_name(counter));
3556 
3557               else
3558 
3559                 htp.p('<OPTION VALUE="' || v_node_id(counter) ||
3560                 '"> ' || v_node_name(counter));
3561 
3562                end if;
3563 
3564             end loop;
3565 
3566             htp.p('</SELECT>');
3567             htp.p('</TD>');
3568             htp.tableRowClose;
3569 
3570       ELSE
3571          htp.formHidden('i_8','');-- DM Home
3572       END IF;
3573        /*
3574            ---------
3575 	     htp.tableRowOpen;                                -- DM Home Preference
3576 		  htp.tableData(wf_core.translate('WFPREF_DMHOME_PROMPT'),'RIGHT');
3577 		  htp.p('<TD ALGIN="LEFT">');
3578 		  htp.p('<SELECT NAME="i_8" SIZE="1">');
3579 
3580 		  for dm in get_dm loop
3581            if (dm.node_id = dm_node_id) then
3582 
3583 		      htp.p('<OPTION VALUE="' || dm.node_id ||
3584 			    '" SELECTED> ' || dm.node_name);
3585 
3586 		    else
3587 
3588 		      htp.p('<OPTION VALUE="' || dm.node_id ||
3589 			   '"> ' || dm.node_name );
3590 
3591 		     end if;
3592 
3593 		  end loop;
3594 
3595 		  htp.p('</SELECT>');
3596 		  htp.p('</TD>');
3597 	     htp.tableRowClose;
3598 
3599      */
3600         IF l_auth_mode <>'LDAP' THEN
3601 
3602 	     htp.tableRowOpen;                                -- Old Password
3603 		 htp.tableData(c_prompts(4),'RIGHT');
3604 		 htp.tableData(htf.formPassword('i_4','30','50'));
3605 	     htp.tableRowClose;
3606 	     htp.tableRowOpen;                                -- Password
3607 		 htp.tableData(c_prompts(5),'RIGHT');
3608 		 htp.tableData(htf.formPassword('i_5','30','50'));
3609 	     htp.tableRowClose;
3610 	     htp.tableRowOpen;                                -- Repeat Password
3611 		 htp.tableData(c_prompts(6),'RIGHT');
3612 		 htp.tableData(htf.formPassword('i_6','30','50'));
3613 	     htp.tableRowClose;
3614         ELSE
3615 	     htp.formHidden('i_4','');-- Old Password
3616         htp.formHidden('i_5','');-- Password
3617         htp.formHidden('i_6','');-- Repeat Password
3618         END IF;
3619          htp.tableClose;
3620          htp.nl;
3621 
3622         htp.formClose;   --userpref
3623 
3624 
3625      l_actions(0).name := 'Cancel';
3626      l_actions(0).text := wf_core.translate('CANCEL');
3627      l_actions(0).actiontype := 'function';
3628      l_actions(0).action := 'top.main.cancelpref()';  -- put your own commands here
3629      l_actions(0).targetframe := 'main';
3630      l_actions(0).enabled := 'b_enabled';
3631      l_actions(0).gap := 'b_narrow_gap';
3632 
3633      l_actions(1).name := 'Apply';
3634      l_actions(1).text := wf_core.translate('APPLY');
3635      l_actions(1).actiontype := 'function';
3636      l_actions(1).action := 'top.main.savepref()';  -- put your own commands here
3637      l_actions(1).targetframe := 'main';
3638      l_actions(1).enabled := 'b_enabled';
3639      l_actions(1).gap := 'b_narrow_gap';
3640 
3641      if p_message_flag = 'N' then
3642         icx_cabo.buttons(p_actions => l_actions);
3643 
3644      elsif p_message_flag = 'Y' then
3645         fnd_message.set_name('ICX','ICX_SUCCESS_CONFIRM');
3646         l_actiontext := fnd_message.get;
3647         icx_cabo.buttons(p_actions    => l_actions,
3648                          p_actiontext => l_actiontext);
3649      else
3650         -- retrieve the password change/validation error returned by fnd_user_pvt
3651         l_actiontext := p_message_flag;
3652         icx_cabo.buttons(p_actions    => l_actions,
3653                          p_actiontext => l_actiontext);
3654      end if;
3655 
3656      htp.bodyClose;
3657      htp.htmlClose;
3658 
3659   end if;  --validatesession
3660 
3661 exception
3662    when others then
3663       fnd_message.set_name('ICX','ICX_SESSION_FAILED');
3664       c_error_msg := fnd_message.get;
3665       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
3666       c_login_msg := fnd_message.get;
3667 
3668       OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
3669 end;
3670 
3671 --  ***********************************************
3672 --     Procedure displayNewPassword
3673 --  ***********************************************
3674 procedure displayNewPassword(i_1         in VARCHAR2,
3675                              c_url       in VARCHAR2,
3676                              c_mode_code in VARCHAR2) is
3677 
3678 c_language_code         varchar2(30);
3679 c_title                 varchar2(240);
3680 c_prompts               icx_util.g_prompts_table;
3681 l_message               varchar2(2000);
3682 l_pwlen                 number;
3683 c_error_msg             varchar2(2000);
3684 c_login_msg             varchar2(2000);
3685 c_error_message         varchar2(240);
3686 
3687 begin
3688         if (i_1 is null) or (i_1 = 'GUEST')
3689      then
3690 
3691 fnd_message.set_name('IBE','IBE_PRMT_UNAUTHORIZED');
3692 c_error_message := fnd_message.get;
3693 htp.p(c_error_message);
3694 else
3695 
3696         c_language_code := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
3697         htp.htmlOpen;
3698         htp.headOpen;
3699         --icx_util.copyright;
3700         htp.p('<SCRIPT LANGUAGE="JavaScript">');
3701         icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpmp.htm');
3702         htp.p('function update_user(){
3703         var l_alert = false;');
3704 
3705     l_pwlen := to_number(nvl(Fnd_Profile.Value('SIGNON_PASSWORD_LENGTH'), 5));
3706     fnd_message.set_name('FND','PASSWORD-LONGER');
3707     fnd_message.set_token('LENGTH',to_char(l_pwlen));
3708     l_message := icx_util.replace_quotes(fnd_message.get);
3709     htp.p('    var lpwd = document.newpass.i_3.value;
3710              if (lpwd.length <  '||to_char(l_pwlen)||' '||'&'||'&'||' document.newpass.i_2.value != "") {
3711                 alert('''||l_message||''');
3712                 document.newpass.i_3.focus();
3713                 l_alert = true
3714                 };');
3715 --start bug 2214425
3716     fnd_message.set_name('FND', 'PASSWORD-INVALID-NO-REUSE');
3717     l_message := icx_util.replace_quotes(fnd_message.get);
3718     htp.p('    if ((document.newpass.i_2.value == document.newpass.i_3.value)||(document.newpass.i_2.value == "" '||'&'||'&'||' document.newpass.i_3.value !="")) {
3719             alert('''||l_message||''');
3720  document.newpass.i_3.focus();
3721         l_alert = true
3722          };');
3723 ----- end
3724 
3725 
3726     fnd_message.set_name('ICX','ICX_REQU_REPAS');
3727     l_message := icx_util.replace_quotes(fnd_message.get);
3728     htp.p('    if ((document.newpass.i_3.value != document.newpass.i_4.value)||(document.newpass.i_2.value == "" '||'&'||'&'||' document.newpass.i_3.value !="")) {
3729         alert('''||l_message||''');
3730         document.newpass.i_4.focus();
3731                 l_alert = true
3732                 };');
3733 
3734         htp.p('    if (l_alert==false) {
3735 document.newpass.submit()
3736              };
3737         }');
3738 
3739         htp.p('</SCRIPT>');
3740         htp.headClose;
3741 
3742         icx_util.getPrompts(601,'ICX_NEW_PASSWORD',c_title,c_prompts);
3743 
3744         /* use Oracle logo */
3745         icx_admin_sig.toolbar(language_code => c_language_code,
3746 			      DISP_MAINMENU => 'N',
3747 			      DISP_HELP => 'N',
3748 			      DISP_EXIT => 'N');
3749 
3750 	fnd_message.set_name('FND','PASSWORD-EXPIRED');
3751 	c_title := fnd_message.get;
3752 
3753         htp.title(c_title);
3754         htp.p('<H2>'||c_title||'</H2>');
3755 
3756         --switched the following statments so correct URL is created in stateful environment MPUTMAN
3757         --htp.formOpen(icx_plug_utilities.getPLSQLagent || 'OracleApps.UNP','POST','','','NAME="newpass"');
3758         htp.formOpen('OracleApps.UNP','POST','','','NAME="newpass"');
3759 
3760         htp.formHidden('i_1', i_1);
3761         htp.formHidden('c_url', c_url);
3762         htp.formHidden('c_mode_code', c_mode_code);
3763 
3764 htp.tableOpen;
3765    htp.tableRowOpen;                                -- Old Password
3766         htp.tableData(c_prompts(2),'RIGHT');
3767         htp.tableData(htf.formPassword('i_2','30','50'));
3768    htp.tableRowClose;
3769    htp.tableRowOpen;                                -- Password
3770         htp.tableData(c_prompts(3),'RIGHT');
3771         htp.tableData(htf.formPassword('i_3','30','50'));
3772    htp.tableRowClose;
3773    htp.tableRowOpen;                                -- Repeat Password
3774         htp.tableData(c_prompts(4),'RIGHT');
3775         htp.tableData(htf.formPassword('i_4','30','50'));
3776    htp.tableRowClose;
3777 htp.tableClose;
3778         htp.nl;
3779 
3780 icx_util.DynamicButton(P_ButtonText => c_prompts(5),
3781                        P_ImageFileName => 'FNDBSBMT',
3782                        P_OnMouseOverText => c_prompts(5),
3783                        P_HyperTextCall => 'javascript:update_user()',
3784                        P_LanguageCode => c_language_code,
3785                        P_JavaScriptFlag => FALSE);
3786         htp.formClose;
3787         htp.bodyClose;
3788         htp.p('<SCRIPT>');  --2330653
3789         htp.p('document.newpass.i_2.focus();'); --2330653
3790         htp.p('</SCRIPT>'); --2330653
3791         htp.htmlClose;
3792 
3793 end if;
3794 
3795 exception
3796    when others then
3797       fnd_message.set_name('ICX','ICX_SESSION_FAILED');
3798       c_error_msg := fnd_message.get;
3799       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
3800       c_login_msg := fnd_message.get;
3801 
3802       OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
3803 end;
3804 
3805 
3806 
3807 --  ***********************************************
3808 --     Procedure updateWebUser
3809 --  ***********************************************
3810 procedure updateWebUser(c_KNOWN_AS    in VARCHAR2,
3811                         c_LANGUAGE    in VARCHAR2,
3812 		                  c_DATE_FORMAT in VARCHAR2,
3813                         c_PASSWORD1   in VARCHAR2,
3814                         c_PASSWORD2   in VARCHAR2,
3815                         c_PASSWORD3   in VARCHAR2,
3816                         c_MAILPREF    in VARCHAR2,
3817                         c_DMPREF      in VARCHAR2,
3818                         c_NUMERIC_CHARACTERS in VARCHAR2,
3819                         c_TERRITORY   in VARCHAR2,
3820                         c_TIMEZONE    IN VARCHAR2,
3821                         c_ENCODING    IN VARCHAR2) is
3822 
3823 l_server_name           varchar2(80);
3824 l_server_port           varchar2(80);
3825 l_password_updated	boolean;
3826 l_date_format		varchar2(100);
3827 n_date_format		varchar2(100);
3828 l_user_id		varchar2(15);
3829 n_session_id		number;
3830 l_session_mode          varchar2(30);
3831 c_language_code		varchar2(30);
3832 c_encrypted_psswd	varchar2(1000);
3833 c_error_msg		varchar2(2000);
3834 c_login_msg		varchar2(2000);
3835 b_return		BOOLEAN;
3836 l_return_status		varchar2(5);
3837 l_msg_count		number;
3838 username                varchar2(30);
3839 l_msg_data		varchar2(2000);
3840 l_message		varchar2(2000);
3841 p_lang_change  VARCHAR2(2000); --added mputman bug 1405228
3842 l_url          VARCHAR2(2000); --added mputman bug 1405228
3843 l_agent        VARCHAR2(2000); --added mputman bug 1405228
3844 l_return_stat  BOOLEAN := TRUE;
3845 prof_date_lang VARCHAR2(80);
3846 prof_sort      VARCHAR2(80);
3847 p_db_nls_language varchar2(80);
3848 p_db_nls_date_format varchar2(30);
3849 p_db_nls_date_language varchar2(80);
3850 p_db_nls_numeric_characters varchar2(5);
3851 p_db_nls_sort varchar2(30);
3852 p_db_nls_territory varchar2(80);
3853 p_db_nls_charset varchar2(80);
3854 z_date_lang VARCHAR2(80);
3855 z_sort VARCHAR2(80);
3856 
3857 
3858 begin
3859 
3860  if icx_sec.validateSession
3861  then
3862 
3863    l_date_format := c_DATE_FORMAT;
3864    l_user_id := icx_sec.g_user_id;
3865    n_session_id := icx_sec.g_session_id;
3866    l_password_updated := TRUE;
3867 
3868    --put timezone profile value
3869 
3870                l_return_stat := FND_PROFILE.SAVE(X_NAME =>'FND_NATIVE_CLIENT_ENCODING',
3871                                                  X_VALUE         => c_ENCODING,
3872                                                  X_LEVEL_NAME    =>'USER',
3873                                                  X_LEVEL_VALUE   => l_user_id);
3874 
3875                l_return_stat := FND_PROFILE.SAVE(X_NAME =>'CLIENT_TIMEZONE_ID',
3876                                                  X_VALUE         => c_TIMEZONE,
3877                                                  X_LEVEL_NAME    =>'USER',
3878                                                  X_LEVEL_VALUE   => l_user_id);
3879            if l_return_stat = FALSE then
3880 
3881               fnd_message.set_name('FND','SQL-NO INSERT');
3882               fnd_message.set_token('TABLE','FND_USER');
3883               fnd_msg_pub.Add;
3884            END IF;
3885 
3886 
3887    -- put the mail preference
3888    wfa_sec.GetSession(username);
3889    username := upper(username);
3890    fnd_preference.put (username, 'WF', 'MAILTYPE', c_mailpref);
3891    -- put the dm home node preference
3892    fnd_document_management.set_dm_home (username, c_dmpref);
3893 
3894    if c_PASSWORD1 is not null or c_PASSWORD2 is not null or c_PASSWORD3 is not null
3895    then
3896 
3897       if c_PASSWORD2 = c_PASSWORD3
3898       then
3899 
3900 	l_server_name := owa_util.get_cgi_env('SERVER_NAME');
3901 	l_server_port := owa_util.get_cgi_env('SERVER_PORT');
3902 
3903            FND_USER_PVT.Update_User(p_api_version_number => 1.0,
3904                                     p_init_msg_list => 'T',
3905                                     p_commit => 'T',
3906 				    p_host_port => l_server_name||':'||l_server_port,
3907 				    p_old_password => c_PASSWORD1,
3908 				    p_new_password => c_PASSWORD2,
3909                                     p_last_updated_by => l_user_id,
3910                                     p_last_update_date => sysdate,
3911                                     p_user_id => l_user_id,
3912                                     p_return_status => l_return_status,
3913                                     p_msg_count => l_msg_count,
3914                                     p_msg_data => l_msg_data);
3915 	 if l_return_status = FND_API.G_RET_STS_ERROR
3916 	 then
3917 	     l_password_updated := FALSE;
3918          end if; -- update password
3919       else
3920 	  l_password_updated := FALSE;
3921       end if; -- c_PASSWORD2 = c_PASSWORD3
3922 
3923       if not l_password_updated
3924       then
3925 
3926       c_error_msg := fnd_message.get;  -- get the password update error placed on the stack by fnd_user_pvt
3927       displaywebuserlocal(p_message_flag => c_error_msg);
3928 /*
3929          c_language_code := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
3930 	 fnd_message.set_encoded(l_msg_data);
3931 --         fnd_message.set_name('ICX','ICX_PWD_CHG_INVALID');
3932          c_error_msg := fnd_message.get;
3933 
3934          htp.htmlOpen;
3935          htp.headOpen;
3936 	 icx_util.copyright;
3937 
3938          htp.p('<SCRIPT LANGUAGE="JavaScript">');
3939 	 htp.p('<!-- Hide from old Browsers');
3940          icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpmp.htm');
3941 	 htp.p('// -->');
3942          htp.p('</SCRIPT>');
3943          htp.headClose;
3944          icx_admin_sig.Openheader( NULL, NULL, c_language_code);
3945          icx_admin_sig.Closeheader( c_language_code);
3946             htp.p(c_error_msg);
3947          htp.htmlClose;
3948 */
3949 
3950       end if;  -- not l_password_updated
3951     end if;
3952 
3953         l_date_format := replace(upper(l_date_format), 'YYYY', 'RRRR');
3954         l_date_format := replace(l_date_format, 'YY', 'RRRR');
3955         if (instr(l_date_format, 'RR') > 0) then
3956             if (instr(l_date_format, 'RRRR')  = 0) then
3957                 l_date_format := replace(l_date_format, 'RR', 'RRRR');
3958             end if;
3959         end if;
3960 
3961     begin
3962 	n_date_format := to_char(sysdate, nvl(l_date_format,'XXX'));
3963     exception
3964 	when others then
3965 	    fnd_message.set_name('ICX','ICX_USE_DATE_FORMAT');
3966 	    fnd_message.set_token('FORMAT_MASK_TOKEN','DD/MM/RRRR');
3967 	    l_message := fnd_message.get;
3968             icx_util.add_error(l_message);
3969             icx_admin_sig.error_screen(l_message);
3970 	    l_password_updated := FALSE;
3971     end;
3972 
3973     if l_password_updated
3974     then
3975 
3976            FND_USER_PVT.Update_User(p_api_version_number => 1.0,
3977                                     p_init_msg_list => 'T',
3978                                     p_commit => 'T',
3979 				    p_language => c_LANGUAGE,
3980 				    p_date_format_mask => l_date_format,
3981                                     p_territory => c_TERRITORY,
3982                                     p_numeric_characters => c_NUMERIC_CHARACTERS,
3983                                     p_known_as => c_KNOWN_AS,
3984                                     p_last_updated_by => l_user_id,
3985                                     p_last_update_date => sysdate,
3986                                     p_user_id => l_user_id,
3987                                     p_return_status => l_return_status,
3988                                     p_msg_count => l_msg_count,
3989                                     p_msg_data => l_msg_data);
3990 
3991 
3992            -- select added mputman bug 1405228
3993            select  nls_language
3994               into    p_lang_change
3995               from    fnd_languages
3996               where   language_code = (SELECT language_code
3997                                        FROM icx_sessions
3998                                        WHERE session_id = n_session_id);
3999 
4000       select  language_code
4001       into    c_language_code
4002       from    fnd_languages
4003       where   nls_language = c_LANGUAGE;
4004       -- bug 2656698
4005       -- get prof option vals for date_lang and sort.
4006       -- call fnd_global.set_nls to get return vals for date_lang and sort.
4007       -- when the prof vals are null, use the returns from fnd_global in the update to icx_sessions.
4008 
4009    fnd_profile.get(name    => 'ICX_NLS_SORT',
4010                    val     => prof_sort);
4011    fnd_profile.get(name    => 'ICX_DATE_LANGUAGE',
4012                    val     => prof_date_lang);
4013 
4014       fnd_global.set_nls(
4015               p_nls_language => c_LANGUAGE,
4016               p_nls_date_format => l_date_format,
4017               p_nls_date_language => NULL,
4018               p_nls_numeric_characters => c_NUMERIC_CHARACTERS,
4019               p_nls_sort => NULL,
4020               p_nls_territory => c_TERRITORY,
4021               p_db_nls_language => p_db_nls_language,
4022               p_db_nls_date_format => p_db_nls_date_format,
4023               p_db_nls_date_language => p_db_nls_date_language,
4024               p_db_nls_numeric_characters => p_db_nls_numeric_characters,
4025               p_db_nls_sort => p_db_nls_sort,
4026               p_db_nls_territory => p_db_nls_territory,
4027               p_db_nls_charset => p_db_nls_charset);
4028 
4029       IF (prof_sort IS NULL) THEN
4030         z_sort :=p_db_nls_sort;    --profile is not null.. use profile value
4031       ELSE
4032         z_sort :=prof_sort;        --profile is null.. use value returned from fnd_global
4033       END IF;
4034 
4035       IF (prof_date_lang IS NULL) THEN
4036          z_date_lang :=p_db_nls_date_language; --profile is not null.. use profile value
4037       ELSE
4038         z_date_lang :=prof_date_lang;         --profile is null.. use value returned from fnd_global
4039       END IF;
4040       --added date_lang and sort to the update for 2656698
4041       update  icx_sessions
4042       set     nls_language = c_LANGUAGE,
4043               language_code = c_language_code,
4044 	           date_format_mask = l_date_format,
4045               nls_territory  = c_TERRITORY,
4046               nls_numeric_characters = c_NUMERIC_CHARACTERS,
4047               nls_date_language = z_date_lang,
4048               nls_sort = z_sort
4049       where   session_id = n_session_id;
4050 
4051       --if added mputman bug 1405228
4052       IF p_lang_change=c_language THEN
4053          displaywebuserlocal;
4054       ELSE
4055          IF (substr(icx_plug_utilities.getPLSQLagent, 1, 1) = '/') then
4056             l_agent := FND_WEB_CONFIG.WEB_SERVER||substr(icx_plug_utilities.getPLSQLagent,2);
4057 
4058          ELSE
4059             l_agent := FND_WEB_CONFIG.WEB_SERVER||icx_plug_utilities.getPLSQLagent;
4060 
4061          end if;
4062 
4063          l_url:=l_agent||'OracleApps.displaywebuser';
4064          l_url:='"'||l_url||'"';
4065 
4066          htp.p('
4067 
4068 
4069                <script language="JavaScript">
4070                function menuBypass(url){
4071                top.location=url;
4072                }
4073                </script>
4074 
4075                <frameset cols="100%,*" frameborder=no border=0>
4076 
4077                <frame
4078                 src=javascript:parent.menuBypass('||l_url||')
4079                 name=hiddenFrame1
4080                 marginwidth=0
4081                 marginheight=0
4082                 scrolling=no>
4083 
4084 
4085                </frameset>
4086 
4087                ');
4088 
4089 
4090 
4091          END IF;-- p_lang_change=c_language
4092     end if;
4093 
4094  end if;
4095 exception
4096    when others then
4097 --htp.p(SQLERRM);
4098   htp.p(dbms_utility.format_error_stack);
4099 
4100 /*
4101       fnd_message.set_name('ICX','ICX_SESSION_FAILED');
4102       c_error_msg := fnd_message.get;
4103       fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
4104       c_login_msg := fnd_message.get;
4105       OracleApps.displayLogin(c_error_msg||' '||c_login_msg,'IC','Y');
4106 */
4107 end;
4108 
4109 --  ***********************************************
4110 --     Procedure Update New Password
4111 --  ***********************************************
4112 procedure UNP(
4113                 i_1         in      varchar2,
4114                 i_2         in      varchar2,
4115                 i_3         in      varchar2,
4116                 i_4         in      varchar2,
4117                 c_mode_code in      varchar2,
4118                 c_url       in      VARCHAR2) is
4119 
4120 c_error_message varchar2(2000);
4121 err_mesg varchar2(240);
4122 err_num number;
4123 
4124 begin
4125 
4126   if c_url is null then
4127      updateNewPassword(i_1,i_2,i_3,i_4);
4128   else
4129      updateNewFndPassword(i_1,i_2,i_3,i_4,c_mode_code,c_url);
4130   end if;
4131 
4132 end;
4133 
4134 --  ***********************************************
4135 --     Procedure updateNewFndPassword
4136 --  ***********************************************
4137 procedure updateNewFndPassword(c_USERNAME  in VARCHAR2,
4138                                c_PASSWORD1 in VARCHAR2,
4139                                c_PASSWORD2 in VARCHAR2,
4140                                c_PASSWORD3 in VARCHAR2,
4141                                p_mode_code in varchar2,
4142                                c_url       in varchar2) is
4143 
4144 l_user_id		number;
4145 l_server                varchar2(240);
4146 l_host_instance		varchar2(240);
4147 l_password_updated      boolean;
4148 c_language_code         varchar2(30);
4149 c_error_msg             varchar2(2000);
4150 c_login_msg             varchar2(2000);
4151 l_username		varchar2(100);
4152 l_password		varchar2(240);
4153 l_web_password          varchar2(240);
4154 v_encrypted_psswd       varchar2(1000);
4155 v_encrypted_upper_psswd varchar2(1000);
4156 l_url                   varchar2(2000);
4157 l_result                varchar2(30);
4158 b_return                BOOLEAN;
4159 l_return_status         varchar2(5);
4160 l_msg_count             number;
4161 l_msg_data              varchar2(2000);
4162 l_message               varchar2(2000);
4163 l_session_id            number;
4164 return_to_url           varchar2(2000);
4165 l_ret_msg               varchar(256);
4166 
4167 begin
4168 
4169    l_password_updated := TRUE;
4170 
4171    if c_PASSWORD1 is not null or c_PASSWORD2 is not null or c_PASSWORD3 is not null
4172    then
4173 
4174       if c_PASSWORD2 = c_PASSWORD3
4175       then
4176 	l_username := UPPER(c_username);
4177 
4178         l_result := fnd_web_sec.change_password(l_username, c_PASSWORD1,
4179                                                     c_PASSWORD2, c_PASSWORD3);
4180 	if l_result = 'N'
4181 	then
4182 	   l_password_updated := FALSE;
4183            l_ret_msg := fnd_message.get;    --bug 2766487
4184 	end if; -- result
4185       else
4186 	    l_password_updated := FALSE;
4187             l_ret_msg := fnd_message.get;    --bug 2766487
4188       end if; -- c_PASSWORD2 = c_PASSWORD3
4189 
4190       if not l_password_updated
4191       then
4192 	 c_language_code := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
4193          fnd_message.set_name('ICX','ICX_PWD_CHG_INVALID');
4194 	 c_error_msg := fnd_message.get;
4195 
4196          htp.htmlOpen;
4197          htp.headOpen;
4198          icx_util.copyright;
4199 
4200          htp.p('<SCRIPT LANGUAGE="JavaScript">');
4201          htp.p('<!-- Hide from old Browsers');
4202          icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpmp.htm');
4203          htp.p('// -->');
4204          htp.p('</SCRIPT>');
4205          htp.headClose;
4206          icx_admin_sig.Openheader( NULL, NULL, c_language_code);
4207          icx_admin_sig.Closeheader( c_language_code);
4208             htp.p(c_error_msg);
4209             htp.nl;
4210             htp.p(l_ret_msg);   --bug 2766487
4211          htp.htmlClose;
4212       else
4213 
4214         --l_server := rtrim(FND_WEB_CONFIG.WEB_SERVER,'/'); -- mputman removed 1574527
4215         --return_to_url := l_server || c_url;               -- mputman removed 1574527
4216           return_to_url := c_url;
4217         --insert into mbuk_url values (return_to_url);
4218         -- c_url is the url where the user should be returned after the
4219         -- password has been successfully changed.
4220 
4221         l_message := icx_sec.validatePassword(c_user_name     => c_USERNAME,
4222                                               c_user_password => c_PASSWORD2,
4223 		 	                      n_session_id    => l_session_id,
4224                                               c_mode_code     => p_mode_code);
4225         htp.htmlOpen;
4226         htp.bodyOpen(cattributes => 'onLoad="top.location.href='''||return_to_url||'''"'); htp.nl;
4227         htp.bodyClose;
4228         htp.htmlClose;
4229 
4230       end if;  -- not l_password_updated
4231     end if;
4232 exception
4233    when others then
4234 --htp.p(SQLERRM);
4235   htp.p(dbms_utility.format_error_stack);
4236 end;
4237 
4238 --  ***********************************************
4239 --     Procedure updateNewPassword
4240 --  ***********************************************
4241 procedure updateNewPassword(c_USERNAME  in VARCHAR2,
4242                             c_PASSWORD1 in VARCHAR2,
4243                             c_PASSWORD2 in VARCHAR2,
4244                             c_PASSWORD3 in VARCHAR2) is
4245 
4246 l_user_id		number;
4247 l_server_name           varchar2(240);
4248 l_server_port           varchar2(80);
4249 l_server                varchar2(240);
4250 l_host_instance		varchar2(240);
4251 l_password_updated      boolean;
4252 c_language_code         varchar2(30);
4253 c_error_msg             varchar2(2000);
4254 c_login_msg             varchar2(2000);
4255 l_username		varchar2(100);
4256 l_password		varchar2(240);
4257 l_web_password          varchar2(240);
4258 v_encrypted_psswd       varchar2(1000);
4259 v_encrypted_upper_psswd varchar2(1000);
4260 l_url                   varchar2(2000);
4261 l_result                varchar2(30);
4262 b_return                BOOLEAN;
4263 l_return_status varchar2(5);
4264 l_msg_count number;
4265 l_msg_data varchar2(2000);
4266 l_message varchar2(2000);
4267 
4268 begin
4269 
4270    l_password_updated := TRUE;
4271 
4272    if c_PASSWORD1 is not null or c_PASSWORD2 is not null or c_PASSWORD3 is not null
4273    then
4274 
4275       if c_PASSWORD2 = c_PASSWORD3
4276       then
4277 
4278 	l_username := UPPER(c_username);
4279         v_encrypted_upper_psswd := to_char(icx_call.crchash(l_username,UPPER(c_PASSWORD1)));
4280 
4281         v_encrypted_psswd := to_char(icx_call.crchash(l_username,c_PASSWORD1));
4282 
4283         select user_id,web_password
4284         into   l_user_id,l_web_password
4285         from   fnd_user
4286         where  user_name = l_username;
4287 
4288 	if l_web_password = v_encrypted_upper_psswd
4289 	then
4290 	    v_encrypted_psswd := v_encrypted_upper_psswd;
4291         elsif l_web_password = v_encrypted_psswd
4292 	then
4293             v_encrypted_psswd := v_encrypted_psswd;
4294 	else
4295 	    v_encrypted_psswd := 'XXXXXXXXXXXXXXX';
4296 	end if;
4297 
4298         l_result := fnd_web_sec.upgrade_web_password(l_username, v_encrypted_psswd,
4299                                                                    c_PASSWORD2);
4300         if l_result = 'N'
4301 	then
4302             l_password_updated := FALSE;
4303 	end if; -- result
4304       else
4305           l_password_updated := FALSE;
4306       end if; -- c_PASSWORD2 = c_PASSWORD3
4307 
4308       if not l_password_updated
4309       then
4310 	 c_language_code := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
4311          fnd_message.set_name('ICX','ICX_PWD_CHG_INVALID');
4312 	 c_error_msg := fnd_message.get;
4313 
4314          htp.htmlOpen;
4315          htp.headOpen;
4316          icx_util.copyright;
4317 
4318          htp.p('<SCRIPT LANGUAGE="JavaScript">');
4319          htp.p('<!-- Hide from old Browsers');
4320          icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpmp.htm');
4321          htp.p('// -->');
4322          htp.p('</SCRIPT>');
4323          htp.headClose;
4324          icx_admin_sig.Openheader( NULL, NULL, c_language_code);
4325          icx_admin_sig.Closeheader( c_language_code);
4326             htp.p(c_error_msg);
4327          htp.htmlClose;
4328       else
4329 
4330         commit; -- 2752387
4331 	oraclemypage.home(rmode => 2,
4332                           i_1 => c_USERNAME,
4333                           i_2 => c_PASSWORD2);
4334 
4335       end if;  -- not l_password_updated
4336     end if;
4337 exception
4338    when others then
4339 --htp.p(SQLERRM);
4340   htp.p(dbms_utility.format_error_stack);
4341 end;
4342 
4343 procedure icxLogin (rmode in number,
4344                     i_1   in varchar2,
4345                     i_2   in varchar2) is
4346 
4347 l_message     varchar2(80);
4348 l_session_id  pls_integer;
4349 l_mode_code   varchar2(30);
4350 
4351 begin
4352 
4353    if rmode = 1 then
4354       l_mode_code := '115J';
4355    elsif rmode = 2 then
4356       l_mode_code := '115P';
4357    end if;
4358 
4359   l_message := icx_sec.validatePassword(c_user_name     => i_1,
4360                                         c_user_password => i_2,
4361 	  	 	                               n_session_id    => l_session_id,
4362                                         c_mode_code     => l_mode_code);
4363 
4364 exception
4365    when others then
4366 --     htp.p(SQLERRM);
4367        htp.p(dbms_utility.format_error_stack);
4368 end;
4369 
4370 procedure DF(i_direct  IN VARCHAR2,
4371              i_mode    IN NUMBER)
4372    IS
4373 
4374 BEGIN
4375 
4376    IF icx_sec.validatesession(c_validate_only=>'Y') THEN
4377       htp.p('<SCRIPT>');
4378       htp.p('this.location="'||i_direct||'"');
4379       htp.p('</SCRIPT>');
4380    ELSE
4381       htp.p('<SCRIPT>');
4382       htp.p('this.location="OracleApps.displayLogin?i_direct='||i_direct||'&i_mode='||i_mode||'"');
4383       htp.p('</SCRIPT>');
4384 
4385    END IF;
4386 
4387 END; -- end DF
4388 
4389 /* Bug 1673370 - wrapper function for forms to call to get one time use ticket.
4390 We need this wrapper to encrypt2() since no commit can be done in forms - also
4391 we do not want commits in normal ICX code - so we add this server side call to
4392 isolate the commit to just the ticket insert */
4393 
4394 function FormsLF_prep(c_string     varchar2,
4395 			             c_session_id NUMBER)
4396          return varchar2 is
4397 PRAGMA AUTONOMOUS_TRANSACTION;
4398 
4399 encrypted_ids      varchar2(512);
4400 
4401 begin
4402 
4403 	encrypted_ids := icx_call.encrypt2( c_string, c_session_id);
4404 	commit;
4405 	return encrypted_ids;
4406 
4407 end; -- FormsLF_prep
4408 
4409 PROCEDURE recreate_session (i_1 IN VARCHAR2,
4410                            i_2 IN VARCHAR2,
4411                            p_enc_session IN VARCHAR2,
4412                            p_mode IN VARCHAR2)
4413    IS
4414    l_validated VARCHAR2(10);
4415    l_server_name VARCHAR2(200); --MPUTMAN added for 2214199
4416    l_domain_count NUMBER;  --MPUTMAN added for 2214199
4417    l_browser VARCHAR2(400);  --MPUTMAN added for 2214199
4418    l_browser_is_IE BOOLEAN;  --MPUTMAN added for 2214199
4419 BEGIN
4420    l_validated:=icx_sec.recreate_session(i_1,i_2,p_enc_session,p_mode);
4421 
4422    --/*  Fix not ready for release.  Will release in future patch.
4423    --begin fix for 2214199
4424    l_browser := owa_util.get_cgi_env('HTTP_USER_AGENT');
4425    IF (instrb(l_browser,'MSIE')>0) THEN
4426       l_browser_is_IE := TRUE;
4427    ELSE
4428       l_browser_is_IE := FALSE;
4429    END IF;
4430    IF l_browser_is_IE THEN
4431      l_server_name := owa_util.get_cgi_env('SERVER_NAME');
4432      l_domain_count := instr(l_server_name,'.',-1,2);
4433      if l_domain_count > 0
4434          then
4435          l_domain_count := instr(l_server_name,'.',1,1);
4436          l_server_name := substr(l_server_name,l_domain_count,length(l_server_name));
4437          l_domain_count := instr(l_server_name,'.',-1,3);
4438          IF  l_domain_count > 0 THEN
4439             l_server_name := substr(l_server_name,l_domain_count,length(l_server_name));
4440             END IF;--SECOND domain count
4441             end if;--FIRST domain count
4442                   IF ((instr(l_server_name,'.',1,1))=1) THEN
4443                     l_server_name:=substr(l_server_name,2);
4444                   END IF;
4445 
4446             --l_server_name now holds the domain value.
4447             htp.p('<script>
4448                    document.domain="'||l_server_name||'"
4449                    </script>');
4450             END IF;--l_browser_is_IE
4451 
4452             --end fix for 2214199
4453    --*/ -- mputman
4454 
4455 
4456    IF  l_validated ='1' THEN
4457 
4458       htp.p('<script>
4459 
4460             window.name="";
4461             if (opener){
4462                 if (opener != null) {
4463                 parent.opener.location.reload();
4464                 }
4465             }
4466             window.close();');
4467 
4468       htp.p('</script>');
4469 
4470    ELSE
4471       htp.p('<script>
4472 
4473             window.name="";
4474             if (opener){
4475                 if (opener != null) {
4476                 parent.opener.location.reload();
4477                 }
4478             }
4479             window.close();');
4480 
4481       htp.p('</script>');
4482 
4483    END IF;
4484 END;
4485 
4486 --  ***********************************************
4487 --     Procedure connectLogin
4488 --  ***********************************************
4489 procedure connectLogin(c_message in VARCHAR2,
4490 		                 c_display in VARCHAR2,
4491 		                 c_logo    in VARCHAR2,
4492                        c_mode IN NUMBER,
4493                        c_lang IN VARCHAR2)
4494 is
4495    c_session_id            number;
4496 	c_language_code		varchar2(30);
4497    c_title		 	varchar2(80);
4498    c_prompts		icx_util.g_prompts_table;
4499    l_host_instance varchar2(80);
4500    l_agent  varchar2(80);
4501    l_text VARCHAR2(240);
4502    c_error_msg VARCHAR2(240);
4503    c_login_msg VARCHAR2(240);
4504    l_nls_lang VARCHAR2(30);
4505    c_nls_language VARCHAR2(40);
4506    c_upper_lang VARCHAR2(30);
4507    b_hosted BOOLEAN DEFAULT FALSE;
4508    l_hosted_profile VARCHAR2(50);
4509 BEGIN
4510 
4511    if  c_lang is not null
4512    then
4513       c_upper_lang:=upper(c_lang);
4514       begin
4515          select  b.language_code, b.nls_language
4516             into    c_language_code, c_nls_language
4517             from    fnd_languages b
4518             where   b.language_code = c_upper_lang;
4519 
4520 
4521          exception
4522             when NO_DATA_FOUND then
4523 
4524                select        LANGUAGE_CODE, nls_language
4525                   into          c_language_code, c_nls_language
4526                   from          FND_LANGUAGES
4527                   where         INSTALLED_FLAG = 'B';
4528                end;
4529                FND_GLOBAL.set_nls_context(p_nls_language =>c_nls_language);
4530        --c_nls_language := ''''||c_nls_language||'''';
4531        --dbms_session.set_nls('NLS_LANGUAGE'   , c_nls_language);--removed in favor of above call to fnd_global -- mputman
4532        end if;
4533    fnd_profile.get(name    => 'ENABLE_SECURITY_GROUPS',
4534                    val     => l_hosted_profile);
4535 
4536    IF (upper(l_hosted_profile)='HOSTED') THEN
4537       b_hosted:=TRUE;
4538    END IF;
4539    icx_util.getPrompts(601,'ICX_LOGIN',c_title,c_prompts);
4540    icx_util.copyright;
4541    htp.p('<META Http-Equiv="Pragma" Content="no-cache">');
4542    htp.title(c_title);
4543    htp.p('<SCRIPT LANGUAGE="JavaScript">');
4544    htp.p('function logon_submit()
4545                      {
4546                      document.Logon0.i_1.value = document.Logon1.i_1.value;
4547                      document.Logon0.i_2.value = document.Logon2.i_2.value;');
4548    IF b_hosted THEN
4549               htp.p('document.Logon0.c_sec_grp_id.value = document.Logon3.site.value;');
4550    END IF;
4551               htp.p('document.Logon0.submit();
4552                      }');  --mputman hosted update
4553    htp.p('</SCRIPT>');
4554    htp.p('<SCRIPT LANGUAGE="JavaScript">');
4555    htp.p('<!-- Hide from old Browsers');
4556    icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpl.htm', c_language_code);
4557    htp.p('// -->');
4558    htp.p('</SCRIPT>');
4559    if c_display = 'IC' and c_logo = 'Y'
4560       then
4561       htp.img(curl => '/OA_MEDIA/FNDLOGOS.gif',
4562               cattributes => 'BORDER=0');
4563       htp.tableRowClose;
4564       htp.tableClose;
4565       htp.line;
4566       end if;
4567    htp.p(nvl(c_message,'<H2>'||c_title||'</H2>'));
4568    l_host_instance := FND_WEB_CONFIG.DATABASE_ID;
4569    l_agent := icx_plug_utilities.getPLSQLagent;
4570    htp.p('<FORM NAME=Logon0 ACTION="OracleMyPage.Home" METHOD="POST" TARGET="_top">');
4571    htp.formHidden('i_1','');
4572    htp.formHidden('i_2','');
4573    htp.formHidden('c_sec_grp_id','');             --mputman hosted update
4574    htp.formHidden('rmode','2');
4575    htp.formClose;
4576    htp.tableOpen;
4577 
4578    IF b_hosted THEN
4579    htp.tableRowOpen;                             -- SITE --mputman hosted update
4580    htp.tableData(c_prompts(5),'RIGHT');
4581    htp.p('<FORM NAME=Logon3 ACTION="javascript:document.Logon1.i_1.focus();" METHOD="POST">');
4582    htp.tableData(htf.formText('site',30));
4583    htp.formClose;
4584    htp.p('<td></td>');
4585    htp.tableRowClose;
4586    END IF;
4587 
4588    htp.tableRowOpen;                             -- Username
4589    htp.tableData(c_prompts(1),'RIGHT');
4590    htp.p('<FORM NAME=Logon1 ACTION="javascript:document.Logon2.i_2.focus();" METHOD="POST">');
4591    htp.tableData(htf.formText('i_1',30));
4592    htp.formClose;
4593    htp.p('<td></td>');
4594    htp.tableRowClose;
4595    htp.tableRowOpen;                             -- Password
4596    htp.tableData(c_prompts(2),'RIGHT');
4597    htp.p('<FORM NAME=Logon2 ACTION="javascript:logon_submit();" METHOD="POST">');
4598    htp.tableData(htf.formPassword('i_2',30));
4599    htp.formClose;
4600    htp.p('<td>');
4601    icx_plug_utilities.buttonBoth(c_prompts(3),'javascript:logon_submit()','FNDJLFOK.gif'); --  Connect
4602    htp.p('</td>');
4603    htp.tableRowClose;
4604    htp.tableClose;
4605    htp.formClose;
4606    htp.p('<SCRIPT LANGUAGE="JavaScript">');
4607    htp.p('<!-- Hide from old Browsers');
4608    htp.p('document.Logon1.i_1.focus();');
4609    htp.p('// -->');
4610    htp.p('</SCRIPT>');
4611 exception
4612    when others then
4613 --        htp.p(SQLERRM);
4614           htp.p(dbms_utility.format_error_stack);
4615 end;
4616 
4617 --  ***********************************************
4618 --     Procedure convertSession
4619 --  ***********************************************
4620 procedure convertSession(c_token in VARCHAR2,
4621                       i_1 IN VARCHAR2,
4622                       i_2 IN VARCHAR2,
4623                       i_S IN VARCHAR2,
4624                       c_message in VARCHAR2)
4625 
4626 is
4627 
4628 PRAGMA AUTONOMOUS_TRANSACTION;
4629 
4630    c_session_id            number;
4631 	c_language_code		varchar2(30);
4632    c_title		 	varchar2(80);
4633    c_prompts		icx_util.g_prompts_table;
4634    l_host_instance varchar2(80);
4635    l_agent  varchar2(80);
4636    --l_text VARCHAR2(240);
4637    c_error_msg VARCHAR2(240);
4638    c_login_msg VARCHAR2(240);
4639    l_nls_lang VARCHAR2(30);
4640    c_nls_language VARCHAR2(40);
4641    c_upper_lang VARCHAR2(30);
4642    b_hosted BOOLEAN DEFAULT FALSE;
4643    l_hosted_profile VARCHAR2(50);
4644 
4645 l_text varchar2(2000);
4646 l_parameters    icx_on_utilities.v2000_table;
4647 l_resp_appl_id number;
4648 l_responsibility_id number;
4649 l_security_group_id number;
4650 l_function_id number;
4651 l_function_type varchar2(30);
4652 l_menu_id number;
4653 l_session_id number;
4654 l_url VARCHAR2(800);
4655 l_validated VARCHAR2(5);
4656 l_message VARCHAR2(600);
4657 l_user_id NUMBER;
4658 l_enc_params VARCHAR2(2000);
4659 
4660  l_language     varchar2(80);
4661  l_language_code      varchar2(30);
4662  l_date_format     varchar2(150);
4663  l_date_language      varchar2(30);
4664  l_numeric_characters varchar2(30);
4665  l_nls_sort        varchar2(30);
4666  l_nls_territory         varchar2(30);
4667  l_limit_time      number;
4668  l_limit_connects  number;
4669  l_multi_org_flag        varchar2(1);
4670  l_org_id                varchar2(50);
4671    l_apps_sso VARCHAR2(20);
4672    l_portal        BOOLEAN DEFAULT FALSE;
4673    l_portal_sso    BOOLEAN DEFAULT FALSE;
4674    l_SSWA          BOOLEAN DEFAULT FALSE;
4675    l_SSWA_SSO      BOOLEAN DEFAULT FALSE;
4676    l_use_portal    BOOLEAN DEFAULT FALSE;
4677    e_portal_no_sso EXCEPTION;
4678 
4679  l_timeout               number;
4680  l_new_xsid       varchar2(32);
4681 
4682 BEGIN
4683    --add redirect code to send to portal and sso if portal agent profile is not null
4684         fnd_profile.get(name    => 'APPS_SSO',
4685                         val     => l_apps_sso);
4686         IF l_apps_sso = 'PORTAL' THEN
4687             l_portal:=TRUE;
4688         ELSIF l_apps_sso = 'SSO_SDK' THEN
4689             l_portal_sso:=TRUE;
4690         ELSIF l_apps_sso = 'SSWA' THEN
4691             l_SSWA:=TRUE;
4692         ELSIF l_apps_sso = 'SSWA_SSO' THEN
4693             l_SSWA_SSO:=TRUE;
4694         ELSIF l_apps_sso IS NULL THEN
4695             l_SSWA:=TRUE;
4696         END IF;
4697         IF l_portal OR l_portal_sso THEN
4698             l_use_portal:=TRUE;
4699             ELSE
4700             l_use_portal:=FALSE;
4701         END IF;
4702 --   htp.p('MPUTMAN - ConvertSession Begin');
4703 
4704    IF l_use_portal THEN -- just a double check
4705 
4706       IF l_portal_sso THEN
4707 
4708          OracleSSWA.convertSession;
4709       ELSIF l_portal THEN
4710 
4711          RAISE e_portal_no_sso;
4712       END IF;
4713    ELSE
4714 
4715    fnd_profile.get(name    => 'ENABLE_SECURITY_GROUPS',
4716                    val     => l_hosted_profile);
4717 
4718    IF (upper(l_hosted_profile)='HOSTED') THEN
4719       b_hosted:=TRUE;
4720    END IF;
4721     --this is not a portal instance, let ICX code do it's magic!
4722       l_text := icx_call.decrypt(c_token);
4723 
4724       icx_on_utilities.unpack_parameters(l_text,l_parameters);
4725       l_session_id := l_parameters(1);
4726       l_resp_appl_id := nvl(l_parameters(2),178);
4727       l_responsibility_id := l_parameters(3);
4728       l_security_group_id := l_parameters(4);
4729       l_function_id := l_parameters(5);
4730       l_enc_params := l_parameters(6);
4731       l_language_code := l_parameters(7);
4732 
4733       IF l_language_code IS NOT NULL THEN
4734         BEGIN
4735           select nls_language
4736             into l_language
4737             from fnd_languages_vl
4738             where LANGUAGE_CODE = l_language_code;
4739           FND_GLOBAL.set_nls_context(p_nls_language => l_language);
4740 
4741           EXCEPTION
4742            WHEN OTHERS THEN
4743            l_language_code :='';   -- bogus value, set to null
4744         END;
4745      END IF;
4746       --make sure session is valid too.
4747       IF (icx_sec.check_session(l_session_id) <> 'INVALID') THEN
4748 
4749         IF ((i_1 IS NOT NULL) AND (i_2 IS NOT NULL)) THEN
4750 
4751           IF ((b_hosted) AND (i_S IS NOT NULL)) THEN
4752 
4753             fnd_global.SET_SECURITY_GROUP_ID_CONTEXT(i_S);
4754             --fnd_global.apps_initialize(user_id => -1,
4755             --                           resp_id => -1,
4756             --                           resp_appl_id => -1,
4757             --                           security_group_id => i_S);--mputman hosted update
4758           END IF;
4759           --htp.p('MPUTMAN - pre validate pwd');htp.nl;
4760          l_validated := fnd_web_sec.validate_login(upper(i_1), i_2);
4761          IF l_validated ='N' THEN --login failed
4762          --htp.p('MPUTMAN - pwd NOT validated');htp.nl;
4763          fnd_message.set_name('ICX','ICX_SIGNIN_INVALID');
4764          l_message := fnd_message.get;
4765          fnd_message.set_name('ICX','ICX_SIGNIN_AGAIN');
4766          l_message := l_message||' '||fnd_message.get;
4767 
4768          OracleApps.convertSession(c_token => c_token,
4769                                    c_message =>l_message);
4770          ELSE  --valid login
4771              --htp.p('MPUTMAN - PWD VALID');htp.nl;
4772             --update session for new user.
4773             BEGIN
4774                SELECT user_id
4775                INTO l_user_id
4776                FROM fnd_user
4777                WHERE user_name = upper(i_1);
4778 
4779                icx_sec.setUserNLS(l_user_id,
4780                                   l_language,
4781                                   l_language_code,
4782                                   l_date_format,
4783                                   l_date_language,
4784                                   l_numeric_characters,
4785                                   l_nls_sort,
4786                                   l_nls_territory,
4787                                   l_limit_time,
4788                                   l_limit_connects,
4789                                   l_org_id,
4790                                   l_timeout);
4791 
4792                SELECT user_id INTO l_org_id FROM icx_sessions WHERE session_id=l_session_id;
4793                l_org_id:='';
4794 
4795 
4796                -- Session Hijacking. Re-set XSID whenever icx session is re-established.
4797                l_new_xsid := fnd_session_management.NewXSID;
4798                UPDATE icx_sessions
4799                SET user_id = l_user_id,
4800                    first_connect = SYSDATE,
4801                    last_connect = SYSDATE,
4802                    counter =1,
4803                    nls_language = l_language,
4804                    language_code = l_language_code,
4805 		             date_format_mask = l_date_format,
4806                    nls_date_language = l_date_language,
4807 		             nls_numeric_characters = l_numeric_characters,
4808 		             nls_sort = l_nls_sort,
4809 		             nls_territory = l_nls_territory,
4810              		 limit_time = l_limit_time,
4811 		             limit_connects = l_limit_connects,
4812          RESPONSIBILITY_APPLICATION_ID = l_resp_appl_id,
4813          RESPONSIBILITY_ID = l_responsibility_id,
4814          SECURITY_GROUP_ID = l_security_group_id,
4815          FUNCTION_ID = l_function_id,
4816                    org_id = l_org_id,
4817                    xsid = l_new_xsid
4818                WHERE session_id = l_session_id;
4819                COMMIT;
4820                -- Session Hijacking. As XSID is modified, send the new XSID value
4821                icx_sec.sendsessioncookie(l_session_id);
4822                EXCEPTION
4823                WHEN OTHERS THEN
4824                NULL;
4825                   END;
4826             --htp.p('MPUTMAN - pre VSP');htp.nl;
4827             icx_sec.g_prog_appl_id := -999;--need to set back everywhere!!
4828 
4829             IF (icx_sec.VALIDATESessionPrivate(c_session_id => l_session_id,
4830                                                c_function_id => l_function_id,
4831                                                c_validate_only =>'Y')) THEN
4832             icx_sec.g_prog_appl_id := -1;
4833            --run it
4834            /*
4835            OracleApps.runfunction(p_resp_appl_id => l_resp_appl_id,
4836                                   p_responsibility_id => l_responsibility_id,
4837                                   p_security_group_id => nvl(l_security_group_id,'0'),
4838                                   p_function_type => f_type,
4839                                   c_function_id => l_function_id,
4840                                   n_session_id => icx_Sec.g_session_id,
4841                                   c_parameters => l_params);
4842 
4843            */
4844            IF l_enc_params IS NOT NULL THEN
4845             OracleApps.runFunction(p_resp_appl_id => l_resp_appl_id,
4846                                   p_responsibility_id => l_responsibility_id,
4847                                   p_security_group_id => nvl(l_security_group_id,'0'),
4848                                   c_function_id => l_function_id,
4849                                   n_session_id  => l_session_id,
4850                                   c_parameters => icx_call.decrypt(l_enc_params));
4851 
4852            ELSE
4853             OracleApps.runFunction(p_resp_appl_id => l_resp_appl_id,
4854                                   p_responsibility_id => l_responsibility_id,
4855                                   p_security_group_id => nvl(l_security_group_id,'0'),
4856                                   c_function_id => l_function_id,
4857                                   n_session_id  => l_session_id);
4858            END IF;
4859             -- htp.p('SUCCESS!!!!');
4860         ELSE
4861           icx_sec.g_prog_appl_id := -1;
4862           OracleApps.convertSession(c_token => c_token);
4863         END IF;
4864         icx_sec.g_prog_appl_id := -1;
4865 
4866          END IF;   --validate_login
4867       ELSE --i_1 || i_2 are null
4868 
4869 
4870  -------------
4871    icx_util.getPrompts(601,'ICX_LOGIN',c_title,c_prompts);
4872    icx_util.copyright;
4873    htp.p('<META Http-Equiv="Pragma" Content="no-cache">');
4874    htp.title(c_title);
4875    htp.p('<SCRIPT LANGUAGE="JavaScript">');
4876    htp.p('function logon_submit()
4877                      {
4878                      document.Logon0.i_1.value = document.Logon1.i_1.value;
4879                      document.Logon0.i_2.value = document.Logon2.i_2.value;');
4880    IF b_hosted THEN
4881               htp.p('document.Logon0.i_S.value = document.Logon3.site.value;');
4882    END IF;
4883               htp.p('document.Logon0.submit();
4884                      }');  --mputman hosted update
4885    htp.p('</SCRIPT>');
4886    htp.p('<SCRIPT LANGUAGE="JavaScript">');
4887    htp.p('<!-- Hide from old Browsers');
4888    icx_admin_sig.help_win_script('/OA_DOC/'||c_language_code||'/aic/icxhlpl.htm', c_language_code);
4889    htp.p('// -->');
4890    htp.p('</SCRIPT>');
4891 --   if c_display = 'IC' and c_logo = 'Y'
4892 --      then
4893       htp.img(curl => '/OA_MEDIA/FNDLOGOS.gif',
4894               cattributes => 'BORDER=0');
4895       htp.tableRowClose;
4896       htp.tableClose;
4897       htp.line;
4898 --      end if;
4899    htp.p(nvl(c_message,'<H2>'||c_title||'</H2>'));
4900    l_host_instance := FND_WEB_CONFIG.DATABASE_ID;
4901    l_agent := icx_plug_utilities.getPLSQLagent;
4902    htp.p('<FORM NAME=Logon0 ACTION="OracleApps.convertSession" METHOD="POST" TARGET="_top">');
4903    --htp.formHidden('c_token',wfa_html.conv_special_url_chars(c_token));
4904    htp.formHidden('c_token',c_token);
4905    htp.formHidden('i_1','');
4906    htp.formHidden('i_2','');
4907    htp.formHidden('i_S','');
4908    htp.formClose;
4909 
4910    IF b_hosted THEN
4911    htp.tableRowOpen;                             -- SITE --mputman hosted update
4912    htp.tableData(c_prompts(5),'RIGHT');
4913    htp.p('<FORM NAME=Logon3 ACTION="javascript:document.Logon1.i_1.focus();" METHOD="POST">');
4914    htp.tableData(htf.formText('site',30));
4915    htp.formClose;
4916    htp.p('<td></td>');
4917    htp.tableRowClose;
4918    END IF;
4919 
4920    htp.tableOpen;
4921    htp.tableRowOpen;                             -- Username
4922    htp.tableData(c_prompts(1),'RIGHT');
4923    htp.p('<FORM NAME=Logon1 ACTION="javascript:document.Logon2.i_2.focus();" METHOD="POST">');
4924    htp.tableData(htf.formText('i_1',30));
4925    htp.formClose;
4926    htp.p('<td></td>');
4927    htp.tableRowClose;
4928    htp.tableRowOpen;                             -- Password
4929    htp.tableData(c_prompts(2),'RIGHT');
4930    htp.p('<FORM NAME=Logon2 ACTION="javascript:logon_submit();" METHOD="POST">');
4931    htp.tableData(htf.formPassword('i_2',30));
4932    htp.formClose;
4933    htp.p('<td>');
4934    icx_plug_utilities.buttonBoth(c_prompts(3),'javascript:logon_submit()','FNDJLFOK.gif'); --  Connect
4935    htp.p('</td>');
4936    htp.tableRowClose;
4937    htp.tableClose;
4938    htp.formClose;
4939    htp.p('<SCRIPT LANGUAGE="JavaScript">');
4940    htp.p('<!-- Hide from old Browsers');
4941    htp.p('document.Logon1.i_1.focus();');
4942    htp.p('// -->');
4943    htp.p('</SCRIPT>');
4944    END IF;  --i_1 and i_2 null check
4945       ELSE --check_session failed
4946         OracleApps.displayLogin;
4947    END IF; -- check_session
4948  END IF; --portal
4949  COMMIT;
4950 exception
4951    WHEN e_portal_no_sso THEN
4952 
4953       OracleApps.displayLogin;
4954 
4955    when others then
4956    rollback;
4957    icx_sec.g_prog_appl_id := -1;
4958 --        htp.p(SQLERRM);
4959           htp.p(dbms_utility.format_error_stack);
4960 end;
4961 
4962 
4963 end OracleApps;