-
Notifications
You must be signed in to change notification settings - Fork 0
/
launchZCS.jsp
523 lines (479 loc) · 20.1 KB
/
launchZCS.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
<%@ page buffer="8kb" session="true" autoFlush="true" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*,javax.naming.*,com.zimbra.client.ZAuthResult" %>
<%@ page import="com.zimbra.cs.taglib.bean.BeanUtils" %>
<%@ taglib prefix="zm" uri="com.zimbra.zm" %>
<%@ taglib prefix="app" uri="com.zimbra.htmlclient" %>
<%@ taglib prefix="fmt" uri="com.zimbra.i18n" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%!
private static String protocolMode = null;
private static String httpPort = null;
private static String httpsPort = null;
static {
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
protocolMode = (String) envCtx.lookup("protocolMode");
httpPort = (String)envCtx.lookup("httpPort");
httpsPort = (String)envCtx.lookup("httpsPort");
} catch (NamingException ne) {
protocolMode = "http";
}
}
static String getParameter(HttpServletRequest request, String pname, String defValue) {
String value = request.getParameter(pname);
return value != null ? value : defValue;
}
static String getAttribute(HttpServletRequest request, String aname, String defValue) {
Object object = request.getAttribute(aname);
String value = object != null ? String.valueOf(object) : null;
return value != null ? value : defValue;
}
%>
<%
String contextPath = request.getContextPath();
if (contextPath.equals("/")) {
contextPath = "";
}
ZAuthResult authResult = (ZAuthResult) request.getAttribute("authResult");
String skin = authResult.getSkin();
if (skin == null) {
skin = authResult.getPrefs().get("zimbraPrefSkin").get(0);
}
%>
<app:skinAndRedirect defaultSkin="${skin}" />
<%
// Set to expire far in the past.
response.setHeader("Expires", "Tue, 24 Jan 2000 17:46:50 GMT");
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
// Prevent IE from ever going into compatibility/quirks mode.
response.setHeader("X-UA-Compatible", "IE=edge");
%>
<!DOCTYPE html>
<zm:getUserAgent var="ua" session="false"/>
<!--
For supporting web client offline mode in Firefox, Cache-control header has to be set for this page for offline usage. overrideCacheControl attribute is set in the session in offline.jsp
-->
<c:if test="${ua.isFirefox && sessionScope.overrideCacheControl}">
<%
response.setHeader("Cache-control", "max-age=2595600");
%>
<c:remove var="overrideCacheControl" scope="session" />
</c:if>
<% java.util.List<String> localePref = authResult.getPrefs().get("zimbraPrefLocale");
if (localePref != null && localePref.size() > 0) {
request.setAttribute("localeId", localePref.get(0));
}
boolean isDev = getParameter(request, "dev", "0").equals("1");
if (isDev) {
request.setAttribute("mode", "mjsf");
request.setAttribute("gzip", "false");
request.setAttribute("fileExtension", "");
if (request.getAttribute("debug") == null) {
request.setAttribute("debug", "1");
}
request.setAttribute("packages", "dev");
}
boolean isCoverage = getParameter(request, "coverage", "0").equals("1");
if (isCoverage) {
request.setAttribute("gzip", "false");
if (request.getAttribute("debug") == null) {
request.setAttribute("debug", "0");
}
request.setAttribute("packages", "dev");
}
boolean isScriptErrorOn = getParameter(request, "scripterrors", "0").equals("1");
String debug = getParameter(request, "debug", getAttribute(request, "debug", null));
debug = BeanUtils.cook(debug);
String debugLogTarget = getParameter(request, "log", getAttribute(request, "log", null));
debugLogTarget = BeanUtils.cook(debugLogTarget);
String extraPackages = getAttribute(request, "packages", null);
String startApp = getParameter(request, "app", "");
String noSplashScreen = getParameter(request, "nss", null);
noSplashScreen = BeanUtils.cook(noSplashScreen);
String virtualAcctDomain = getParameter(request, "virtualacctdomain", null);
boolean isLeakDetectorOn = getParameter(request, "leak", "0").equals("1");
String mode = getAttribute(request, "mode", null);
boolean isDevMode = mode != null && mode.equalsIgnoreCase("mjsf");
boolean isSkinDebugMode = mode != null && mode.equalsIgnoreCase("skindebug");
boolean isPerfMetric = getParameter(request, "perfMetric", "0").equals("1");
String vers = getAttribute(request, "version", "");
String prodMode = getAttribute(request, "prodMode", "");
String ext = getAttribute(request, "fileExtension", null);
if (ext == null || isDevMode || isCoverage) ext = "";
String offlineMode = getParameter(request, "offline", application.getInitParameter("offlineMode"));
Locale locale = request.getLocale();
String localeId = getAttribute(request, "localeId", null);
if (localeId != null) {
localeId = BeanUtils.cook(localeId);
int index = localeId.indexOf("_");
if (index == -1) {
locale = new Locale(localeId);
} else {
String language = localeId.substring(0, index);
String country = localeId.substring(localeId.length() - 2);
locale = new Locale(language, country);
}
}
String unitTest = getParameter(request, "unittest", "");
String preset = getParameter(request, "preset", "");
// make variables available in page context (e.g. ${foo})
pageContext.setAttribute("contextPath", contextPath);
pageContext.setAttribute("skin", skin);
pageContext.setAttribute("ext", ext);
pageContext.setAttribute("vers", vers);
pageContext.setAttribute("app", startApp);
pageContext.setAttribute("locale", locale);
pageContext.setAttribute("isDevMode", isDev);
pageContext.setAttribute("isScriptErrorOn", isScriptErrorOn);
pageContext.setAttribute("isOfflineMode", offlineMode != null && offlineMode.equals("true"));
pageContext.setAttribute("isProdMode", !prodMode.equals(""));
pageContext.setAttribute("isDebug", isSkinDebugMode || isDevMode);
pageContext.setAttribute("isLeakDetectorOn", isLeakDetectorOn);
pageContext.setAttribute("unitTest", unitTest);
pageContext.setAttribute("preset", preset);
pageContext.setAttribute("isCoverage", isCoverage);
pageContext.setAttribute("isPerfMetric", isPerfMetric);
pageContext.setAttribute("isLocaleId", localeId != null);
pageContext.setAttribute("csrfToken", authResult.getCsrfToken());
%>
<c:set var="lang" value="${fn:substring(pageContext.request.locale, 0, 2)}"/>
<html class="user_font_size_normal" lang="${lang}">
<head>
<!--
launchZCS.jsp
* ***** BEGIN LICENSE BLOCK *****
* Zimbra Collaboration Suite Web Client
* Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Zimbra, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
* ***** END LICENSE BLOCK *****
-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="Pragma" content="no-cache"/>
<fmt:setLocale value='${locale}' scope='request' />
<c:if test="${not isLocaleId}">
<zm:getValidLocale locale='${locale}' var='validLocale' csrftoken="${csrfToken}"/>
<c:if test="${not validLocale}">
<% pageContext.setAttribute("locale", Locale.US); //unsupported locale being set default to US%>
</c:if>
</c:if>
<fmt:setBundle basename="/messages/ZmMsg" scope="request" force="true" />
<title><fmt:message key="zimbraTitle"/></title>
<link href="<c:url value="/css/images,common,dwt,msgview,login,zm,spellcheck,skin.css">
<c:param name="v" value="${vers}" />
<c:param name='debug' value='${isDebug}' />
<c:param name="skin" value="${skin}" />
<c:param name="locale" value="${locale}" />
<c:if test="${not empty param.customerDomain}">
<c:param name="customerDomain" value="${param.customerDomain}" />
</c:if>
</c:url>" rel="stylesheet" type="text/css" />
<c:if test="${not empty unitTest}">
<script>
window.exports = window.UT = {};
window.require = true;
</script>
<link rel="stylesheet" href="/qunit/qunit.css" />
<script src="/qunit/qunit.js"></script>
<script src="/js/zimbraMail/unittest/ZmUnitTestManager.js"></script>
</c:if>
<zm:getFavIcon request="${pageContext.request}" var="favIconUrl" />
<c:if test="${empty favIconUrl}">
<fmt:message key="favIconUrl" var="favIconUrl"/>
</c:if>
<link rel="SHORTCUT ICON" href="<c:url value='${favIconUrl}'/>">
<script>
window.appContextPath = "${zm:jsEncode(contextPath)}";
window.appCurrentSkin = "${zm:jsEncode(skin)}";
window.appExtension = "${zm:jsEncode(ext)}";
window.cacheKillerVersion = "${zm:jsEncode(vers)}";
window.appRequestLocaleId = "${locale}";
window.appDevMode = ${isDevMode};
window.appCoverageMode = ${isCoverage};
window.isScriptErrorOn = ${isScriptErrorOn};
window.isPerfMetric = ${isPerfMetric};
window.authTokenExpires = <%= authResult.getExpires()%>;
window.csrfToken = "${csrfToken}";
window.appLang = "${lang}";
</script>
<noscript>
<meta http-equiv="Refresh" content="0;url=public/noscript.jsp" >
</noscript>
<link rel="stylesheet" href="/css/style-topin2.css" />
</head>
<body>
<div class="top-wrapper">
<div class="top-row">
<a href="https://itcommunications.sk/?page_id=32" class="backtoservices">Späť na moje služby</a>
</div>
</div>
<c:if test="${ua.isChrome or ua.isSafari}">
<%
/*preloading splash screen images to avoid latency*/
String splashLocation = "_base";
//skins that are not related with base login banner
String[] spSkin={"carbon","lake","lemongrass","pebble","tree","twilight","waves"};
for(int i=0;i<spSkin.length;i++){
if(skin.equals(spSkin[i])){
splashLocation=skin;
}
}
/*preloading splash screen images to avoid latency ends*/
%>
<%--preloading the splash screen images to avoid latency --%>
<div style="display:none;">
<img src="<%=contextPath%>/skins/<%=splashLocation%>/logos/LoginBanner.png?v=${vers}" alt=""/>
<%if(splashLocation.equals("lemongrass")){%>
<img src="<%=contextPath%>/skins/<%=splashLocation%>/img/bg_lemongrass.png?v=${vers}" alt=""/>
<%}%>
<%if(splashLocation.equals("waves")){%>
<img src="<%=contextPath%>/skins/<%=splashLocation%>/img/login_bg.png?v=${vers}" alt=""/>
<img src="<%=contextPath%>/skins/<%=splashLocation%>/img/login_page_bg.png?v=${vers}" alt=""/>
<%}%>
</div>
<%--preloading the splash screen images to avoid latency ends --%>
</c:if>
<jsp:include page="Resources.jsp">
<jsp:param name="res" value="I18nMsg,AjxMsg,ZMsg,ZmMsg,AjxKeys,ZmKeys,ZdMsg,AjxTemplateMsg" />
<jsp:param name="skin" value="${skin}" />
<jsp:param name="localeId" value="${locale}" />
</jsp:include>
<!--
################
# BEGIN SKIN #
################
-->
<%-- NOTE: servlet path is needed because the servlet sees it as /public/launchZCS.jsp --%>
<jsp:include page="/html/skin.html">
<jsp:param name="servlet-path" value="/html/skin.html" />
<jsp:param name='client' value='advanced' />
<jsp:param name='skin' value='${skin}' />
<jsp:param name="locale" value="${locale}" />
<jsp:param name='debug' value='${isDebug}' />
<jsp:param name="customerDomain" value="${param.customerDomain}" />
</jsp:include>
<!--
##############
# END SKIN #
##############
-->
<div style='display:none;'>
<jsp:include page="Boot.jsp"/>
<script>
AjxEnv.DEFAULT_LOCALE = "${zm:javaLocaleId(locale)}";
virtualAcctDomain = "<%= (virtualAcctDomain != null) ? virtualAcctDomain : "" %>";
function killSplashScreenSwitch() {
if (!virtualAcctDomain) {
return false;
}
var splSwitch = document.getElementById("splashScreenSwitchContainer");
if (splSwitch) {
splSwitch.style.visibility = 'hidden';
}
}
function switchToStandardClient() {
document.location = window.appContextPath + "/?client=standard";
}
killSplashScreenSwitch();
<c:set var="enforceMinDisplay" value="${requestScope.authResult.prefs.zimbraPrefAdvancedClientEnforceMinDisplay[0]}"/>
<c:if test="${param.client ne 'advanced'}">
enforceMinDisplay = ${enforceMinDisplay ne 'FALSE'};
unsupported = (screen && (screen.width <= 800 && screen.height <= 600) && !${isOfflineMode}) || (AjxEnv.isSafari && !AjxEnv.isSafari4up);
if (enforceMinDisplay && unsupported) {
switchToStandardClient();
}
delete enforceMinDisplay;
delete unsupported;
</c:if>
</script>
<%@ include file="loadImgData.jsp" %>
<script>
<jsp:include page="/js/ajax/util/AjxTimezoneData.js" />
</script>
<%
String allPackages = "Startup1_1,Startup1_2";
if (extraPackages != null) {
if (extraPackages.equals("dev")) {
extraPackages = "Startup2,MailCore,Mail,ContactsCore,CalendarCore,Calendar,CalendarAppt,Contacts,BriefcaseCore,Briefcase,PreferencesCore,Preferences,TasksCore,Tasks,Extras,Share,Zimlet,ZimletApp,Alert,ImportExport,Voicemail";
}
allPackages += "," + BeanUtils.cook(extraPackages);;
}
String pprefix = isDevMode && !isCoverage ? "public/jsp" : "js";
String psuffix = isDevMode && !isCoverage ? ".jsp" : "_all.js";
String[] pnames = allPackages.split(",");
for (String pname : pnames) {
String pageurl = "/" + pprefix + "/" + pname + psuffix;
pageContext.setAttribute("pageurl", pageurl);
if (isDevMode && !isCoverage) { %>
<jsp:include page='${pageurl}' />
<% } else { %>
<script src="${contextPath}${pageurl}${ext}?v=${vers}"></script>
<% } %>
<% }
%>
<%-- Load skin.js first because splash screen has 'switch to basic client' link now --%>
<script type="text/javascript">
<%-- NOTE: servlet path is needed because the servlet sees it as /public/launchZCS.jsp --%>
<jsp:include page='/js/skin.js'>
<jsp:param name='servlet-path' value='/js/skin.js' />
<jsp:param name='client' value='advanced' />
<jsp:param name='skin' value='${skin}' />
<jsp:param name="locale" value="${locale}" />
<jsp:param name='debug' value='${isDebug}' />
<jsp:param name="templates" value="split" />
<jsp:param name="customerDomain" value="${param.customerDomain}" />
</jsp:include>
</script>
<c:if test="${not requestScope['skin.templates.included']}">
<script type="text/javascript" src="<c:url value='/js/skin.js'>
<c:param name='client' value='advanced' />
<c:param name='skin' value='${skin}' />
<c:param name="locale" value="${locale}" />
<c:param name='debug' value='${isDebug}' />
<c:param name="compress" value="${not isDebug}" />
<c:param name="templates" value="only" />
<c:param name="v" value="${vers}" />
<c:if test="${not empty param.customerDomain}">
<c:param name="customerDomain" value="${param.customerDomain}" />
</c:if>
</c:url>"></script>
</c:if>
<script>
// compile locale specific templates
for (pkg in window.AjxTemplateMsg) {
text = AjxTemplateMsg[pkg];
AjxTemplate.compile(pkg, true, false, text);
}
delete pkg;
delete text;
</script>
<script>
function launch() {
// quit if this function has already been called
if (arguments.callee.done) {return;}
// flag this function so we don't do the same thing twice
arguments.callee.done = true;
// kill the timer
if (window._timer) {
clearInterval(window._timer);
delete _timer;
}
var prodMode = ${isProdMode};
var debugLevel = "<%= (debug != null) ? debug : "" %>";
var debugLogTarget = "<%= (debugLogTarget != null) ? debugLogTarget : "" %>";
window.DBG = new AjxDebug({level:AjxDebug.NONE, target:debugLogTarget});
// figure out the debug level
if (debugLevel == 't') {
DBG.showTiming(true);
} else if (debugLevel) {
DBG.setDebugLevel(debugLevel);
}
AjxHistoryMgr.BLANK_FILE = "${contextPath}/public/blankHistory.html";
var noSplashScreen = "<%= (noSplashScreen != null) ? noSplashScreen : "" %>";
var protocolMode = "<%=protocolMode%>";
<c:set var="initialMailSearch" value="${requestScope.authResult.prefs.zimbraPrefMailInitialSearch[0]}"/>
<c:if test="${fn:startsWith(initialMailSearch, 'in:')}">
<c:set var="path" value="${fn:substring(initialMailSearch, 3, -1)}"/>
<c:set var="sortOrder" value="${requestScope.authResult.prefs.zimbraPrefSortOrder[0]}"/>
</c:if>
<c:set var="types" value="${requestScope.authResult.attrs.zimbraFeatureConversationsEnabled[0] eq 'FALSE' ? 'message' : requestScope.authResult.prefs.zimbraPrefGroupMailBy[0]}"/>
<c:set var="numItems" value="${requestScope.authResult.prefs.zimbraPrefItemsPerVirtualPage[0]}"/>
<zm:getInfoJSON var="getInfoJSON"
authtoken="${requestScope.authResult.authToken}"
csrftoken="${csrfToken}"
dosearch="${not empty app and app ne 'mail' or isOfflineMode ? false : true}"
itemsperpage="${numItems * 2}"
types="${types}"
folderpath="${path}"
sortby="${sortOrder}"
fullconversation="true"/>
var batchInfoResponse = ${getInfoJSON};
<c:if test="${not empty app and app eq 'calendar'}">
<zm:calSearchJSON var="calSearchJSON"
authtoken="${requestScope.authResult.authToken}"
csrftoken="${csrfToken}"
timezone="${requestScope.tz}"
itemsperpage="500"
types="appointment"/>
window.inlineCalSearchResponse = ${calSearchJSON};
</c:if>
<c:if test="${isLeakDetectorOn}">
AjxLeakDetector.begin();
</c:if>
// NOTE: Domain info settings moved into launch function to
// prevent sloppy code from accessing extraneous window
// scoped variable.
<zm:getDomainInfo var="domainInfo" by="virtualHostname" value="${zm:getServerName(pageContext)}"/>
var settings = {
"dummy":1
<c:if test="${not empty domainInfo}">
<c:forEach var="info" items="${domainInfo.attrs}">,
"${info.key}":
<c:choose>
<c:when test="${not zm:isCollection(info.value)}">
<%--Single value domain attribute--%>
"${zm:jsEncode(info.value)}"
</c:when>
<c:otherwise>
<%--Multi value domain attribute--%>
<c:set var="infoArray" value="${fn:join(info.value, '\", \"')}"/>
["${infoArray}"]
</c:otherwise>
</c:choose>
</c:forEach>
</c:if>
};
var params = {
app:"${zm:cook(app)}",
settings:settings, batchInfoResponse:batchInfoResponse,
offlineMode:${isOfflineMode}, devMode:${isDevMode},
protocolMode:protocolMode, httpPort:"<%=httpPort%>", httpsPort:"<%=httpsPort%>",
noSplashScreen:noSplashScreen, unitTest:"${unitTest}", preset:"${preset}", virtualAcctDomain : virtualAcctDomain
};
ZmZimbraMail.run(params);
delete virtualAcctDomain;
}
// START DOMContentLoaded
// Mozilla and Opera 9 expose the event we could use
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", launch, null);
// mainly for Opera 8.5, won't be fired if DOMContentLoaded fired already.
document.addEventListener("load", launch, null);
}
// for Internet Explorer. readyState will not be achieved on init call
if (AjxEnv.isIE && AjxEnv.isWindows) {
document.attachEvent("onreadystatechange", function(e) {
if (document.readyState == "complete") {
launch();
}
});
}
if (/(WebKit|khtml)/i.test(navigator.userAgent)) { // sniff
window._timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
launch();
// call the onload handler
}
}, 10);
}
// END DOMContentLoaded
AjxCore.addOnloadListener(launch);
AjxCore.addOnunloadListener(ZmZimbraMail.unload);
</script>
</div>
</body>
</html>