<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<%@ include file="/init.jsp" %>

<%
long companyId = ParamUtil.getLong(request, "preferencesCompanyId");

PortletPreferences companyPortletPreferences = PrefsPropsUtil.getPreferences(companyId);

PortletPreferences systemPortletPreferences = PrefsPropsUtil.getPreferences(0L);

Function<String, String> function = (String key) -> companyPortletPreferences.getValue(key, systemPortletPreferences.getValue(key, PropsUtil.get(key)));
%>

<aui:fieldset>
	<aui:input name="preferencesCompanyId" type="hidden" value="<%= companyId %>" />

	<aui:input cssClass="lfr-input-text-container" label="incoming-pop-server" name="pop3Host" type="text" value="<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_POP3_HOST) %>" />

	<aui:input cssClass="lfr-input-text-container" label="incoming-port" name="pop3Port" type="text" value="<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_POP3_PORT) %>" />

	<aui:input label="use-a-secure-network-connection" name="pop3Secure" type="checkbox" value='<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_STORE_PROTOCOL).equals("pop3s") %>' />

	<aui:input autocomplete="new-password" cssClass="lfr-input-text-container" label="user-name" name="pop3User" type="text" value="<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_POP3_USER) %>" />

	<%
	String pop3Password = function.apply(PropsKeys.MAIL_SESSION_MAIL_POP3_PASSWORD);

	if (Validator.isNotNull(pop3Password)) {
		pop3Password = Portal.TEMP_OBFUSCATION_VALUE;
	}
	%>

	<aui:input autocomplete="new-password" cssClass="lfr-input-text-container" label="password" name="pop3Password" type="password" value="<%= pop3Password %>" />

	<aui:input cssClass="lfr-input-text-container" label="outgoing-smtp-server" name="smtpHost" type="text" value="<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST) %>" />

	<aui:input cssClass="lfr-input-text-container" label="outgoing-port" name="smtpPort" type="text" value="<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_SMTP_PORT) %>" />

	<aui:input label="use-a-secure-network-connection" name="smtpSecure" type="checkbox" value='<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_TRANSPORT_PROTOCOL).equals("smtps") %>' />

	<aui:input label="enable-starttls" name="smtpStartTLSEnable" type="checkbox" value="<%= GetterUtil.getBoolean(function.apply(PropsKeys.MAIL_SESSION_MAIL_SMTP_STARTTLS_ENABLE)) %>" />

	<aui:input autocomplete="new-password" cssClass="lfr-input-text-container" label="user-name" name="smtpUser" type="text" value="<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_SMTP_USER) %>" />

	<%
	String smtpPassword = function.apply(PropsKeys.MAIL_SESSION_MAIL_SMTP_PASSWORD);

	if (Validator.isNotNull(smtpPassword)) {
		smtpPassword = Portal.TEMP_OBFUSCATION_VALUE;
	}
	%>

	<aui:input autocomplete="new-password" cssClass="lfr-input-text-container" label="password" name="smtpPassword" type="password" value="<%= smtpPassword %>" />

	<aui:input cssClass="lfr-textarea-container" label="manually-specify-additional-javamail-properties-to-override-the-above-configuration" name="advancedProperties" type="textarea" value="<%= function.apply(PropsKeys.MAIL_SESSION_MAIL_ADVANCED_PROPERTIES) %>" />
</aui:fieldset>