commit
c9afbac242
@ -1,89 +0,0 @@ |
||||
/* |
||||
This file is part of Libresonic. |
||||
|
||||
Libresonic 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, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
Libresonic 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 Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2016 (C) Libresonic Authors |
||||
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus |
||||
*/ |
||||
package org.libresonic.player.domain; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
|
||||
import org.libresonic.player.service.SettingsService; |
||||
|
||||
/** |
||||
* Controller for the "Podcast receiver" page. |
||||
* |
||||
* @author Sindre Mehus |
||||
*/ |
||||
public class LicenseInfo { |
||||
|
||||
private String licenseEmail; |
||||
private boolean licenseValid; |
||||
private final Date trialExpires; |
||||
private long trialDaysLeft; |
||||
private final Date licenseExpires; |
||||
|
||||
public LicenseInfo(String licenseEmail, boolean licenseValid, Date trialExpires, |
||||
long trialDaysLeft, Date licenseExpires) { |
||||
this.licenseEmail = licenseEmail; |
||||
this.licenseValid = licenseValid; |
||||
this.trialExpires = trialExpires; |
||||
this.trialDaysLeft = trialDaysLeft; |
||||
this.licenseExpires = licenseExpires; |
||||
} |
||||
|
||||
public String getLicenseEmail() { |
||||
return licenseEmail; |
||||
} |
||||
|
||||
public void setLicenseEmail(String licenseEmail) { |
||||
this.licenseEmail = StringUtils.trimToNull(licenseEmail); |
||||
} |
||||
|
||||
public boolean isLicenseValid() { |
||||
return licenseValid; |
||||
} |
||||
|
||||
public void setLicenseValid(boolean licenseValid) { |
||||
this.licenseValid = licenseValid; |
||||
} |
||||
|
||||
public boolean isTrial() { |
||||
return trialExpires != null && !licenseValid; |
||||
} |
||||
|
||||
public boolean isTrialExpired() { |
||||
return trialExpires != null && (trialExpires.before(new Date()) || trialDaysLeft > SettingsService.TRIAL_DAYS + 1); |
||||
} |
||||
|
||||
public boolean isLicenseOrTrialValid() { |
||||
return isLicenseValid() || !isTrialExpired(); |
||||
} |
||||
|
||||
public Date getTrialExpires() { |
||||
return trialExpires; |
||||
} |
||||
|
||||
public long getTrialDaysLeft() { |
||||
return trialDaysLeft; |
||||
} |
||||
|
||||
public Date getLicenseExpires() { |
||||
return licenseExpires; |
||||
} |
||||
} |
@ -1,93 +0,0 @@ |
||||
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="iso-8859-1" %> |
||||
<%--@elvariable id="command" type="org.libresonic.player.command.PremiumSettingsCommand"--%> |
||||
<html> |
||||
<head> |
||||
<%@ include file="head.jsp" %> |
||||
<%@ include file="jquery.jsp" %> |
||||
</head> |
||||
<body class="mainframe bgcolor1"> |
||||
|
||||
<c:import url="settingsHeader.jsp"> |
||||
<c:param name="cat" value="premium"/> |
||||
<c:param name="restricted" value="${not command.user.adminRole}"/> |
||||
<c:param name="toast" value="${settings_toast}"/> |
||||
</c:import> |
||||
|
||||
<c:if test="${not empty command.path}"> |
||||
<sub:url value="main.view" var="backUrl"> |
||||
<sub:param name="path" value="${command.path}"/> |
||||
</sub:url> |
||||
<div class="back"><a href="${backUrl}"> |
||||
<fmt:message key="common.back"/> |
||||
</a></div> |
||||
<br/> |
||||
</c:if> |
||||
|
||||
<div style="width:50em; max-width:50em"> |
||||
|
||||
<fmt:message key="premium.text"/> |
||||
<fmt:formatDate value="${command.licenseInfo.licenseExpires}" dateStyle="long" var="expirationDate"/> |
||||
|
||||
<c:if test="${command.licenseInfo.licenseValid}"> |
||||
<c:choose> |
||||
<c:when test="${empty command.licenseInfo.licenseExpires}"> |
||||
<p><b><fmt:message key="premium.licensed"/></b></p> |
||||
</c:when> |
||||
<c:otherwise> |
||||
<p><b><fmt:message key="premium.licensedexpires"><fmt:param value="${expirationDate}"/></fmt:message></b></p> |
||||
</c:otherwise> |
||||
</c:choose> |
||||
<c:if test="${not command.forceChange and not command.submissionError}"> |
||||
<p> |
||||
<fmt:message key="premium.licensedto"><fmt:param value="${command.licenseInfo.licenseEmail}"/></fmt:message> |
||||
</p> |
||||
<c:if test="${command.user.adminRole}"> |
||||
<div class="forward"><a href="premiumSettings.view?change"><fmt:message key="premium.forcechange"/></a></div> |
||||
</c:if> |
||||
</c:if> |
||||
</c:if> |
||||
|
||||
<c:if test="${not command.licenseInfo.licenseValid}"> |
||||
<c:if test="${not empty command.licenseInfo.licenseExpires}"> |
||||
<p><b><fmt:message key="premium.licensedexpired"><fmt:param value="${expirationDate}"/></fmt:message></b></p> |
||||
</c:if> |
||||
<p class="forward" style="font-size:1.2em;margin-left: 1em"><b><a href="http://libresonic.org/pages/premium.jsp" target="_blank"> |
||||
<fmt:message key="premium.getpremium"/> |
||||
<c:if test="${command.licenseInfo.trialDaysLeft gt 0}"> |
||||
– <fmt:message key="top.trialdaysleft"><fmt:param value="${command.licenseInfo.trialDaysLeft}"/></fmt:message> |
||||
</c:if> |
||||
</a></b></p> |
||||
|
||||
<p><fmt:message key="premium.register"/></p> |
||||
</c:if> |
||||
|
||||
<c:if test="${not command.licenseInfo.licenseValid or command.forceChange or command.submissionError}"> |
||||
<form:form commandName="command" method="post" action="premiumSettings.view"> |
||||
<form:hidden path="path"/> |
||||
<table> |
||||
<tr> |
||||
<td><fmt:message key="premium.register.email"/></td> |
||||
<td> |
||||
<form:input path="licenseInfo.licenseEmail" size="60"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td><fmt:message key="premium.register.license"/></td> |
||||
<td> |
||||
<form:input path="licenseCode" size="60"/> |
||||
</td> |
||||
<td><input type="submit" value="<fmt:message key="common.ok"/>"/></td> |
||||
</tr> |
||||
<tr> |
||||
<td/> |
||||
<td class="warning"><form:errors path="licenseCode"/></td> |
||||
</tr> |
||||
</table> |
||||
</form:form> |
||||
|
||||
<p><fmt:message key="premium.resend"/></p> |
||||
</c:if> |
||||
|
||||
</div> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue