Subversion Repositories general

Compare Revisions

No changes between revisions

Ignore whitespace Rev 26 → Rev 27

/kickup/trunk/build.xml
79,6 → 79,10
dir="${classes}"
includes="**/*.xml"
/>
<fileset
dir="${src}"
includes="**/*.txt"
/>
</copy>
 
<copy todir="${app.web-inf}" flatten="yes">
/kickup/trunk/webapp/WEB-INF/lib/activation.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/kickup/trunk/webapp/WEB-INF/lib/mailapi.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/kickup/trunk/webapp/WEB-INF/lib/smtp.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/kickup/trunk/webapp/WEB-INF/struts-config.xml
30,8 → 30,10
<form-property name="account" type="java.lang.String" />
<form-property name="enabled" type="java.lang.Boolean" />
<form-property name="comment" type="java.lang.String" />
<form-property name="acts" type="ak.kickup.core.form.EventActBean[]" size="1" />
<form-property name="apartments" type="ak.kickup.core.form.EventApartmentBean[]" size="1" />
<form-property name="acts" type="ak.kickup.core.form.EventActBean[]"
size="1" />
<form-property name="apartments" type="ak.kickup.core.form.EventApartmentBean[]"
size="1" />
</form-bean>
 
<form-bean
106,6 → 108,8
<form-property name="payed" type="java.lang.Boolean" />
<form-property name="comment" type="java.lang.String" />
<form-property name="privateComment" type="java.lang.String" />
<form-property name="acts" type="ak.kickup.core.form.ParticipantActBean[]"
size="1" />
</form-bean>
 
<form-bean
126,6 → 130,8
<form-property name="freeSleep" type="java.lang.String" />
<form-property name="sleepComment" type="java.lang.String" />
<form-property name="comment" type="java.lang.String" />
<form-property name="acts" type="ak.kickup.core.form.ParticipantActBean[]"
size="1" />
</form-bean>
 
<form-bean
145,6 → 151,8
<form-property name="freeSleep" type="java.lang.String" />
<form-property name="sleepComment" type="java.lang.String" />
<form-property name="comment" type="java.lang.String" />
<form-property name="acts" type="ak.kickup.core.form.ParticipantActBean[]"
size="1" />
</form-bean>
</form-beans>
 
/kickup/trunk/webapp/admin/participant/edit.jsp
35,15 → 35,15
<table border=1>
<tr>
<th>Кодовый номер</th>
<td><bean:write name="participant" property="ident" />&nbsp;</td>
<td colspan=3><bean:write name="participant" property="ident" />&nbsp;</td>
</tr>
<tr>
<th>Ник</th>
<td><html:text property="nick" /></td>
<td colspan=3><html:text property="nick" /></td>
</tr>
<tr>
<th>e-mail</th>
<td><html:text property="email" /></td>
<td colspan=3><html:text property="email" /></td>
</tr>
<tr>
<th>Показ e-mail разрешен</th>
51,47 → 51,47
</tr>
<tr>
<th>Имя</th>
<td><html:text property="name" /></td>
<td colspan=3><html:text property="name" /></td>
</tr>
<tr>
<th>Телефон</th>
<td><html:text property="phone" /></td>
<td colspan=3><html:text property="phone" /></td>
</tr>
<tr>
<th>Количество человек</th>
<td><html:text property="persons" /></td>
<td colspan=3><html:text property="persons" /></td>
</tr>
<tr>
<th>Выезд из PLZ</th>
<td><html:text property="fromZip" /></td>
<td colspan=3><html:text property="fromZip" /></td>
</tr>
<tr>
<th>Выезд из города</th>
<td><html:text property="fromCity" /></td>
<td colspan=3><html:text property="fromCity" /></td>
</tr>
<tr>
<th>Время отправления</th>
<td><html:text property="departure" /></td>
<td colspan=3><html:text property="departure" /></td>
</tr>
<tr>
<th>Свободных мест в машине</th>
<td><html:text property="freeTransport" /></td>
<td colspan=3><html:text property="freeTransport" /></td>
</tr>
<tr>
<th>Условия транспортировки</th>
<td><html:textarea property="transportComment" /></td>
<td colspan=3><html:textarea property="transportComment" /></td>
</tr>
<tr>
<th>Свободных спальных мест</th>
<td><html:text property="freeSleep" /></td>
<td colspan=3><html:text property="freeSleep" /></td>
</tr>
<tr>
<th>Условия ночевки</th>
<td><html:textarea property="sleepComment" /></td>
<td colspan=3><html:textarea property="sleepComment" /></td>
</tr>
<tr>
<th>Дополнительная информация</th>
<td><html:textarea property="comment" /></td>
<td colspan=3><html:textarea property="comment" /></td>
</tr>
<tr>
<th>Оплачено</th>
99,10 → 99,34
</tr>
<tr>
<th>Комментарии организаторов</th>
<td><html:textarea property="privateComment" /></td>
<td colspan=3><html:textarea property="privateComment" /></td>
</tr>
 
<logic:notEmpty name="actList" property="objects">
<tr>
<th colspan=4>Участвует в</th>
</tr>
<tr>
<td>Название</td>
<td>Включить</td>
<td>Дополнительно</td>
<td>&nbsp;</td>
</tr>
<logic:iterate name="ParticipantEditForm" property="acts" id="acts" indexId="iid">
<tr>
<th>
<bean:write name="actList" property='<%= "objects[" + iid + "].act.name" %>' />
<html:hidden name="acts" property="actId" indexed="true" />
</th>
<td><html:checkbox name="acts" property="selected" indexed="true" /></td>
<td><html:text name="acts" property="comment" indexed="true" /></td>
<td>&nbsp;</td>
</tr>
</logic:iterate>
</logic:notEmpty>
 
<tr>
<td colspan=2>
<td colspan=4>
<html:submit>Сохранить</html:submit>
<backpath:notEmpty><backpath:backlink>Отменить</backpath:backlink></backpath:notEmpty>
</td>
/kickup/trunk/webapp/participant/edit.jsp
35,70 → 35,91
<table border=1>
<tr>
<th>Ваш номер</th>
<td><bean:write name="participant" property="ident" /></td>
<td colspan=2><bean:write name="participant" property="ident" /></td>
</tr>
<tr>
<th>Ник на форуме</th>
<td><bean:write name="participant" property="nick" /></td>
<td colspan=2><bean:write name="participant" property="nick" /></td>
</tr>
<tr>
<th>Ваш e-mail</th>
<td><bean:write name="participant" property="email" /></td>
<td colspan=2><bean:write name="participant" property="email" /></td>
</tr>
<tr>
<th>Разрешить показ e-mail'а</th>
<td colspan=3><html:checkbox property="emailPublic" /></td>
<td colspan=2><html:checkbox property="emailPublic" /></td>
</tr>
<tr>
<th>Сколько вас</th>
<td><html:text property="persons" /></td>
<td colspan=2><html:text property="persons" /></td>
</tr>
 
<tr>
<th>Выезд из PLZ</th>
<td><html:text property="fromZip" /></td>
<td colspan=2><html:text property="fromZip" /></td>
</tr>
<tr>
<th>Выезд из города</th>
<td><html:text property="fromCity" /></td>
<td colspan=2><html:text property="fromCity" /></td>
</tr>
<tr>
<th>Время отправления</th>
<td><html:text property="departure" /></td>
<td colspan=2><html:text property="departure" /></td>
</tr>
<tr>
<th>Свободных мест в машине</th>
<td><html:text property="freeTransport" /></td>
<td colspan=2><html:text property="freeTransport" /></td>
</tr>
<tr>
<th>Условия транспортировки</th>
<td><html:textarea property="transportComment" /></td>
<td colspan=2><html:textarea property="transportComment" /></td>
</tr>
 
<tr>
<th>Свободных спальных мест</th>
<td><html:text property="freeSleep" /></td>
<td colspan=2><html:text property="freeSleep" /></td>
</tr>
<tr>
<th>Условия ночевки</th>
<td><html:textarea property="sleepComment" /></td>
<td colspan=2><html:textarea property="sleepComment" /></td>
</tr>
 
<tr>
<th>Ваше имя</th>
<td><html:text property="name" /></td>
<td colspan=2><html:text property="name" /></td>
</tr>
<tr>
<th>Телефон</th>
<td><html:text property="phone" /></td>
<td colspan=2><html:text property="phone" /></td>
</tr>
<tr>
<th>Дополнительная информация</th>
<td><html:textarea property="comment" /></td>
<td colspan=2><html:textarea property="comment" /></td>
</tr>
 
<logic:notEmpty name="actList" property="objects">
<tr>
<th colspan=3>В чем желаете поучаствовать</th>
</tr>
<tr>
<td>Название</td>
<td>Включить</td>
<td>Дополнительно</td>
</tr>
<logic:iterate name="ParticipantRegisterEditForm" property="acts" id="acts" indexId="iid">
<tr>
<th>
<bean:write name="actList" property='<%= "objects[" + iid + "].act.name" %>' />
<html:hidden name="acts" property="actId" indexed="true" />
</th>
<td><html:checkbox name="acts" property="selected" indexed="true" /></td>
<td><html:text name="acts" property="comment" indexed="true" /></td>
</tr>
</logic:iterate>
</logic:notEmpty>
 
<tr>
<td colspan=2>
<td colspan=3>
<html:submit>Сохранить</html:submit>
<backpath:notEmpty><backpath:backlink>Отменить</backpath:backlink></backpath:notEmpty>
</td>
/kickup/trunk/webapp/participant/register.jsp
34,66 → 34,87
<table border=1>
<tr>
<th>Ник на форуме</th>
<td><html:text property="nick" /></td>
<td colspan=2><html:text property="nick" /></td>
</tr>
<tr>
<th>Ваш e-mail</th>
<td><html:text property="email" /></td>
<td colspan=2><html:text property="email" /></td>
</tr>
<tr>
<th>Разрешить показ e-mail'а</th>
<td colspan=3><html:checkbox property="emailPublic" /></td>
<td colspan=2><html:checkbox property="emailPublic" /></td>
</tr>
<tr>
<th>Сколько вас</th>
<td><html:text property="persons" /></td>
<td colspan=2><html:text property="persons" /></td>
</tr>
 
<tr>
<th>Выезд из PLZ</th>
<td><html:text property="fromZip" /></td>
<td colspan=2><html:text property="fromZip" /></td>
</tr>
<tr>
<th>Выезд из города</th>
<td><html:text property="fromCity" /></td>
<td colspan=2><html:text property="fromCity" /></td>
</tr>
<tr>
<th>Время отправления</th>
<td><html:text property="departure" /></td>
<td colspan=2><html:text property="departure" /></td>
</tr>
<tr>
<th>Свободных мест в машине</th>
<td><html:text property="freeTransport" /></td>
<td colspan=2><html:text property="freeTransport" /></td>
</tr>
<tr>
<th>Условия транспортировки</th>
<td><html:textarea property="transportComment" /></td>
<td colspan=2><html:textarea property="transportComment" /></td>
</tr>
 
<tr>
<th>Свободных спальных мест</th>
<td><html:text property="freeSleep" /></td>
<td colspan=2><html:text property="freeSleep" /></td>
</tr>
<tr>
<th>Условия ночевки</th>
<td><html:textarea property="sleepComment" /></td>
<td colspan=2><html:textarea property="sleepComment" /></td>
</tr>
 
<tr>
<th>Ваше имя</th>
<td><html:text property="name" /></td>
<td colspan=2><html:text property="name" /></td>
</tr>
<tr>
<th>Телефон</th>
<td><html:text property="phone" /></td>
<td colspan=2><html:text property="phone" /></td>
</tr>
<tr>
<th>Дополнительная информация</th>
<td><html:textarea property="comment" /></td>
<td colspan=2><html:textarea property="comment" /></td>
</tr>
 
<logic:notEmpty name="actList" property="objects">
<tr>
<th colspan=3>В чем желаете поучаствовать</th>
</tr>
<tr>
<td>Название</td>
<td>Включить</td>
<td>Дополнительно</td>
</tr>
<logic:iterate name="ParticipantRegisterForm" property="acts" id="acts" indexId="iid">
<tr>
<th>
<bean:write name="actList" property='<%= "objects[" + iid + "].act.name" %>' />
<html:hidden name="acts" property="actId" indexed="true" />
</th>
<td><html:checkbox name="acts" property="selected" indexed="true" /></td>
<td><html:text name="acts" property="comment" indexed="true" /></td>
</tr>
</logic:iterate>
</logic:notEmpty>
 
<tr>
<td colspan=2>
<td colspan=3>
<html:submit>Зарегистрироваться</html:submit>
<backpath:notEmpty><backpath:backlink>Отменить</backpath:backlink></backpath:notEmpty>
</td>
/kickup/trunk/sql/00.tables.sql
153,15 → 153,13
constraint participants_email unique(email)
);
 
/*
create table participant_acts
(
participant integer not null,
event integer not null,
act integer not null,
comment text,
mod_stamp timestamp,
id integer not null,
participant integer not null,
act integer not null,
comment text,
mod_stamp timestamp,
 
constraint participant_acts_prim primary key (participant, event, act)
constraint participant_acts_prim primary key (participant, act)
);
*/
/kickup/trunk/src/ak/kickup/core/RegistrationMail.txt
0,0 → 1,16
Ваш e-mail был использован при регистрации на "%eventName%".
Если вы ничего об этом не знаете - просто проигнорируйте это письмо.
 
Если же все верно, и это вы зарегистрировались, то ваш регистрационный
номер: %ident%. Он понадобится, если вы захотите удалить регистрацию
или изменить свои данные.
 
Участие в "%eventName%" стоит %eventPrice% евро.
Переведите, полжалуйста, деньги на счет:
 
%eventMoneyAccount%
 
В качестве Verwendungszweck укажите ваш номер, %ident%.
 
Если у вас есть вопросы, обращайтесь к организаторам
(%eventAdmins%) по адресу %eventEmail%.
/kickup/trunk/src/ak/kickup/core/action/ParticipantAction.java
27,6 → 27,9
import ak.kickup.core.model.ParticipantManager;
import ak.kickup.core.model.Event;
import ak.kickup.core.model.EventManager;
import ak.kickup.core.model.ParticipantAct;
import ak.kickup.core.model.EventAct;
import ak.kickup.core.form.ParticipantActBean;
 
public final class ParticipantAction
extends Action
44,6 → 47,9
Event event = (eventId == null)
? null : EventManager.getInstance().get(eventId, true);
request.setAttribute("event", event);
 
if("submit".equals(mapping.getParameter()) || "update".equals(mapping.getParameter()))
initLists(request, event);
}
 
if("update".equals(mapping.getParameter())) {
84,7 → 90,18
 
showForm.set("emailPublic", Boolean.TRUE);
 
// acts
List acts = new ArrayList(event.getActCollection());
ParticipantActBean[] a = new ParticipantActBean[acts.size()];
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR);
for(int i = 0; i < acts.size(); i++) {
EventAct act = (EventAct)acts.get(i);
a[i] = new ParticipantActBean(act.getAct(), null);
}
showForm.set("acts", a);
 
request.setAttribute("event", event);
initLists(request, event);
return mapping.findForward("default");
}
else if("login".equals(mapping.getParameter())) {
103,6 → 120,18
throw new UserException("ak.kickup.core.participant.edit.ident.wrong");
}
 
// acts
List acts = new ArrayList(event.getActCollection());
ParticipantActBean[] a = new ParticipantActBean[acts.size()];
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR);
for(int i = 0; i < acts.size(); i++) {
EventAct act = (EventAct)acts.get(i);
a[i] = new ParticipantActBean(act.getAct(),
participant.getAct(act.getAct().getId()));
}
showForm.set("acts", a);
 
// others
showForm.set("emailPublic", participant.getEmailPublic());
showForm.set("name", participant.getName());
showForm.set("phone", participant.getPhone());
117,6 → 146,7
showForm.set("comment", participant.getComment());
 
request.setAttribute("participant", participant);
initLists(request, event);
return mapping.findForward("default");
}
else if("unregister".equals(mapping.getParameter())) {
153,11 → 183,43
"ak.kickup.core.participant.edit.registration.unavailable");
}
 
// acts
ParticipantActBean[] acts = (ParticipantActBean[])theForm.get("acts");
for(int i = 0; i < acts.length; i++) {
// get bean
Long actId = StringConverter.parseLong(acts[i].getActId());
EventAct act = event.getAct(actId);
ParticipantAct participantAct = participant.getAct(actId);
 
if(acts[i].getSelected() == null || !acts[i].getSelected().booleanValue()) {
if(participantAct != null) participant.removeAct(participantAct);
}
else {
if(participantAct == null) {
participantAct = ParticipantManager.getInstance().createAct();
participantAct.setParticipant(participant);
participantAct.setAct(act.getAct());
participant.addAct(participantAct);
}
participantAct.setComment(acts[i].getComment());
}
}
 
// bind
participant.setIdent(ParticipantManager.getInstance().generateIdent());
participant.setEvent(event);
 
// email
String email = (String)theForm.get("email");
if(ParticipantManager.getInstance().emailExists(participant, email)) {
request.setAttribute("event", event);
initLists(request, event);
throw new UserException("ak.kickup.core.participant.email.nonunique");
}
participant.setEmail(email);
 
// others
participant.setNick((String)theForm.get("nick"));
participant.setEmail((String)theForm.get("email"));
participant.setEmailPublic((Boolean)theForm.get("emailPublic"));
participant.setName((String)theForm.get("name"));
participant.setPhone((String)theForm.get("phone"));
173,7 → 235,7
 
ParticipantManager.getInstance().save(participant);
 
// FIXME: send email here
Messages.sendRegistrationMessage(participant, request.getRemoteAddr());
 
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
191,6 → 253,29
throw new ModelSecurityException();
}
 
// acts
ParticipantActBean[] acts = (ParticipantActBean[])theForm.get("acts");
for(int i = 0; i < acts.length; i++) {
// get bean
Long actId = StringConverter.parseLong(acts[i].getActId());
EventAct act = event.getAct(actId);
ParticipantAct participantAct = participant.getAct(actId);
 
if(acts[i].getSelected() == null || !acts[i].getSelected().booleanValue()) {
if(participantAct != null) participant.removeAct(participantAct);
}
else {
if(participantAct == null) {
participantAct = ParticipantManager.getInstance().createAct();
participantAct.setParticipant(participant);
participantAct.setAct(act.getAct());
participant.addAct(participantAct);
}
participantAct.setComment(acts[i].getComment());
}
}
 
// others
participant.setEmailPublic((Boolean)theForm.get("emailPublic"));
participant.setName((String)theForm.get("name"));
participant.setPhone((String)theForm.get("phone"));
213,4 → 298,12
throw new Exception("unknown mapping parameter");
}
}
 
private void initLists(HttpServletRequest request, Event event)
throws Exception
{
List acts = new ArrayList(event.getActCollection());
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR);
request.setAttribute("actList", new ObjectList(acts));
}
}
/kickup/trunk/src/ak/kickup/core/action/AdminParticipantAction.java
26,6 → 26,9
import ak.kickup.core.model.ParticipantManager;
import ak.kickup.core.model.Event;
import ak.kickup.core.model.EventManager;
import ak.kickup.core.model.ParticipantAct;
import ak.kickup.core.model.EventAct;
import ak.kickup.core.form.ParticipantActBean;
 
public final class AdminParticipantAction
extends Action
38,17 → 41,22
if("submit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, false);
Long participantId = StringConverter.parseLong(theForm.get("id"));
Participant participant;
if(participantId == null) {
participant = ParticipantManager.getInstance().create();
if(eventId != null) {
Event event = EventManager.getInstance().get(eventId, false);
Long participantId = StringConverter.parseLong(theForm.get("id"));
Participant participant;
if(participantId == null) {
participant = ParticipantManager.getInstance().create();
}
else {
participant = ParticipantManager.getInstance().get(participantId);
}
request.setAttribute("event", event);
request.setAttribute("participant", participant);
 
initLists(request, event);
// FIXME: if a list is changed between "edit" and "submit" then indicies are wrong
}
else {
participant = ParticipantManager.getInstance().get(participantId);
}
request.setAttribute("event", event);
request.setAttribute("participant", participant);
}
}
 
98,6 → 106,18
showForm.set("privateComment", participant.getPrivateComment());
}
 
// acts
List acts = new ArrayList(event.getActCollection());
ParticipantActBean[] a = new ParticipantActBean[acts.size()];
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR);
for(int i = 0; i < acts.size(); i++) {
EventAct act = (EventAct)acts.get(i);
a[i] = new ParticipantActBean(act.getAct(),
participant.getAct(act.getAct().getId()));
}
showForm.set("acts", a);
 
initLists(request, event);
request.setAttribute("event", event);
request.setAttribute("participant", participant);
return mapping.findForward("default");
115,21 → 135,59
DynaActionForm theForm = (DynaActionForm)form;
Long participantId = StringConverter.parseLong(theForm.get("id"));
Participant participant;
Event event;
boolean newParticipant;
 
// get instance
if(participantId == null) {
Long eventId = StringConverter.parseLong(theForm.get("event"));
Event event = EventManager.getInstance().get(eventId, false);
Long eventId = StringConverter.parseLong(theForm.get("event"));
event = EventManager.getInstance().get(eventId, false);
 
participant = ParticipantManager.getInstance().create();
participant.setIdent(ParticipantManager.getInstance().generateIdent());
participant.setEvent(event);
newParticipant = true;
}
else {
participant = ParticipantManager.getInstance().get(participantId);
event = participant.getEvent();
newParticipant = false;
}
 
// acts
ParticipantActBean[] acts = (ParticipantActBean[])theForm.get("acts");
for(int i = 0; i < acts.length; i++) {
// get bean
Long actId = StringConverter.parseLong(acts[i].getActId());
EventAct act = event.getAct(actId);
ParticipantAct participantAct = participant.getAct(actId);
 
if(acts[i].getSelected() == null || !acts[i].getSelected().booleanValue()) {
if(participantAct != null) participant.removeAct(participantAct);
}
else {
if(participantAct == null) {
participantAct = ParticipantManager.getInstance().createAct();
participantAct.setParticipant(participant);
participantAct.setAct(act.getAct());
participant.addAct(participantAct);
}
participantAct.setComment(acts[i].getComment());
}
}
 
// email
String email = (String)theForm.get("email");
if(ParticipantManager.getInstance().emailExists(participant, email)) {
request.setAttribute("event", event);
request.setAttribute("participant", participant);
initLists(request, event);
throw new UserException("ak.kickup.core.participant.email.nonunique.admin");
}
participant.setEmail(email);
 
// others
participant.setNick((String)theForm.get("nick"));
participant.setEmail((String)theForm.get("email"));
participant.setEmailPublic((Boolean)theForm.get("emailPublic"));
participant.setName((String)theForm.get("name"));
participant.setPhone((String)theForm.get("phone"));
146,6 → 204,9
participant.setPrivateComment((String)theForm.get("privateComment"));
 
ParticipantManager.getInstance().save(participant);
if(newParticipant)
Messages.sendRegistrationMessage(participant, null);
 
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
}
153,4 → 214,12
throw new Exception("unknown mapping parameter");
}
}
 
private void initLists(HttpServletRequest request, Event event)
throws Exception
{
List acts = new ArrayList(event.getActCollection());
Collections.sort(acts, EventManager.ACT_NAME_COMPARATOR);
request.setAttribute("actList", new ObjectList(acts));
}
}
/kickup/trunk/src/ak/kickup/core/action/AdminEventAction.java
92,7 → 92,7
Collections.sort(acts, ActManager.NAME_COMPARATOR);
for(int i = 0; i < acts.size(); i++) {
Act act = (Act)acts.get(i);
a[i] = new EventActBean(act, (event == null) ? null : event.getAct(act.getId()));
a[i] = new EventActBean(act, event.getAct(act.getId()));
}
showForm.set("acts", a);
 
/kickup/trunk/src/ak/kickup/core/CoreResources.properties
2,6 → 2,8
ak.kickup.core.act.name.nonunique=Мероприятие с таким названием уже существует
ak.kickup.core.apartment.name.nonunique=Гостиница с таким названием уже существует
ak.kickup.core.event.name.nonunique=Пьянка с таким названием уже существует
ak.kickup.core.participant.email.nonunique=Этот e-mail уже зарегистрирован на эту пьянку. Если вы забыли свой номер - обратитесь к организаторам.
ak.kickup.core.participant.email.nonunique.admin=Этот e-mail уже зарегистрирован на эту пьянку
ak.kickup.core.access.denied=Сюда нельзя!
ak.kickup.core.event.edit.id.wrong=Неизвестная пьянка, выбирайти из списка
ak.kickup.core.event.edit.name.required=Название обязательно
31,5 → 33,8
ak.kickup.core.participant.edit.ident.wrong=Неизвестный номер
ak.kickup.core.participant.edit.registration.unavailable=Время регистрации прошло
ak.kickup.core.participant.edit.unregistration.unavailable=Время отмены регистрации прошло
ak.kickup.core.mail.send.error=Не могу отправить вам e-mail. Проверьте свой адрес и обратитесь к организаторам.
ak.kickup.core.mail.read.error=Не могу отправить вам e-mail. Ошибка в системе.
ak.kickup.core.mail.subject=Регистрация на {0}
 
org.apache.struts.taglib.bean.format.sql.timestamp=dd.MM.yyyy HH:mm:ss.SSS
/kickup/trunk/src/ak/kickup/core/model/Participant.java
1,6 → 1,11
package ak.kickup.core.model;
 
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
import java.util.Collection;
import java.util.Iterator;
import ak.kickup.util.ModelException;
import ak.kickup.util.ModelSecurityException;
 
29,6 → 34,8
private Boolean payed;
private String comment;
private String privateComment;
private Collection acts; // Collection(ParticipantAct)
private Map actsMap = new HashMap(); // Map(Long id -> ParticipantAct)
 
protected Participant()
{
286,6 → 293,56
this.privateComment = privateComment;
}
 
/**
* @return Collection(ParticipantAct)
*
* @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true"
* @hibernate.collection-key column="participant"
* @hibernate.collection-one-to-many class="ak.kickup.core.model.ParticipantAct"
*/
protected Collection getActs()
{
return acts;
}
 
public Collection getActCollection()
{
return Collections.unmodifiableCollection(acts);
}
 
/**
* @param destinations Collection(ParticipantAct)
*/
protected void setActs(Collection acts)
{
this.acts = acts;
 
actsMap.clear();
if(acts != null) {
for(Iterator i = acts.iterator(); i.hasNext(); ) {
ParticipantAct a = (ParticipantAct)i.next();
actsMap.put(a.getAct().getId(), a);
}
}
}
 
public ParticipantAct getAct(Long actId)
{
return (ParticipantAct)actsMap.get(actId);
}
 
public void addAct(ParticipantAct act)
{
acts.add(act);
actsMap.put(act.getAct().getId(), act);
}
 
public void removeAct(ParticipantAct act)
{
acts.remove(act);
actsMap.remove(act.getAct().getId());
}
 
public boolean equals(Object o)
{
if(o == null || !(o instanceof Participant)) return false;
/kickup/trunk/src/ak/kickup/core/model/ParticipantAct.java
0,0 → 1,64
package ak.kickup.core.model;
 
import java.util.Date;
import ak.kickup.util.ModelException;
import ak.kickup.util.ModelSecurityException;
 
/**
*
* @hibernate.class table="participant_acts"
*/
public class ParticipantAct
extends GeneralModelObject
{
private Participant participant;
private Act act;
private String comment;
private Date modStamp;
 
protected ParticipantAct()
{
}
 
/**
*
* @hibernate.many-to-one
*/
public Participant getParticipant()
{
return participant;
}
 
public void setParticipant(Participant participant)
{
this.participant = participant;
}
 
/**
*
* @hibernate.many-to-one
*/
public Act getAct()
{
return act;
}
 
public void setAct(Act act)
{
this.act = act;
}
 
/**
*
* @hibernate.property
*/
public String getComment()
{
return comment;
}
 
public void setComment(String comment)
{
this.comment = comment;
}
}
/kickup/trunk/src/ak/kickup/core/model/ParticipantManager.java
27,6 → 27,8
try {
HibernateUtil.getConfiguration().addResource(
"ak/kickup/core/model/Participant.hbm.xml");
HibernateUtil.getConfiguration().addResource(
"ak/kickup/core/model/ParticipantAct.hbm.xml");
 
participantManager = new ParticipantManager();
}
82,6 → 84,30
}
}
 
public boolean emailExists(Participant participant, String email)
throws ModelException
{
try {
if(participant.getId() == null)
return ((Integer)HibernateUtil.currentSession().iterate(
"select count(*) from Participant where email=? and event=?",
new Object[] { email, participant.getEvent() },
new Type[] { Hibernate.STRING, Hibernate.entity(Event.class) } )
.next()).intValue() > 0;
else
return ((Integer)HibernateUtil.currentSession().iterate(
"select count(*) from Participant p where email=? and event=? and p!=?",
new Object[] { email, participant.getEvent(), participant },
new Type[] { Hibernate.STRING, Hibernate.entity(Event.class),
Hibernate.entity(Participant.class) } )
.next()).intValue() > 0;
}
catch(HibernateException ex)
{
throw new ModelException(ex);
}
}
 
public String generateIdent()
throws ModelException
{
172,6 → 198,12
}
}
 
public ParticipantAct createAct()
throws ModelException
{
return new ParticipantAct();
}
 
public static final Comparator NICK_COMPARATOR = new NickComparator();
 
private static class NickComparator
/kickup/trunk/src/ak/kickup/core/mail/Messages.java
0,0 → 1,101
package ak.kickup.core.action;
 
import java.util.*;
import java.io.*;
import java.text.MessageFormat;
 
import javax.mail.Session;
import javax.mail.Message;
import javax.mail.Transport;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;
 
import ak.kickup.util.UserException;
import ak.kickup.util.StringConverter;
import ak.kickup.core.model.Participant;
 
public abstract class Messages
{
public static final String HOST = "localhost";
public static final String CHARSET = "UTF8";
 
public static void send(String from, String to, String subject, String body)
throws UserException
{
try {
Properties props = new Properties();
props.put("mail.smtp.host", HOST);
 
Session session = Session.getInstance(props, null);
MimeMessage msg = new MimeMessage(session);
InternetAddress[] address = { new InternetAddress(to) };
 
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject, CHARSET);
msg.setSentDate(new Date());
msg.setText(body, CHARSET);
 
Transport.send(msg);
}
catch(Exception ex) {
throw new UserException("ak.kickup.core.mail.send.error");
}
}
 
public static void sendRegistrationMessage(Participant participant, String ip)
throws UserException
{
String subject;
StringBuffer message = new StringBuffer();
 
// get subject
ResourceBundle res = ResourceBundle.getBundle("ak/kickup/core/CoreResources");
String subjectString = res.getString("ak.kickup.core.mail.subject");
subject = MessageFormat.format(subjectString,
new String[] { participant.getEvent().getName() } );
 
// read message template
try {
ClassLoader cl = Messages.class.getClassLoader();
if(cl == null) cl = ClassLoader.getSystemClassLoader();
 
BufferedReader file = new BufferedReader(new InputStreamReader(cl.getResourceAsStream(
"ak/kickup/core/RegistrationMail.txt"), "UTF8"));
char[] buf = new char[2048];
int bufLen;
while((bufLen = file.read(buf)) >= 0) {
message.append(buf);
}
}
catch(Exception ex) {
throw new UserException("ak.kickup.core.mail.read.error");
}
 
// replace tokens
replace(message, "ident", participant.getIdent());
replace(message, "eventName", participant.getEvent().getName());
replace(message, "eventPrice",
StringConverter.toCurrency(participant.getEvent().getPrice()));
replace(message, "eventMoneyAccount", participant.getEvent().getMoneyAccount());
replace(message, "eventAdmins", participant.getEvent().getAdmins());
replace(message, "eventEmail", participant.getEvent().getEmail());
replace(message, "", "%");
 
// send message
send(participant.getEvent().getEmail(), participant.getEmail(),
subject, message.toString());
}
 
private static void replace(StringBuffer message, String token, String value)
{
String s = "%" + token + "%";
int slen = s.length();
int vlen = value.length();
int pos = 0;
while((pos = message.indexOf(s, pos)) >= 0) {
message.replace(pos, pos + slen, value);
pos += vlen;
}
}
}
/kickup/trunk/src/ak/kickup/core/form/ParticipantActBean.java
0,0 → 1,53
package ak.kickup.core.form;
 
import ak.kickup.util.StringConverter;
import ak.kickup.core.model.ParticipantAct;
import ak.kickup.core.model.Act;
 
public final class ParticipantActBean
{
private String actId;
private String comment;
private Boolean selected;
 
public ParticipantActBean()
{
}
 
public ParticipantActBean(Act act, ParticipantAct info)
{
this.actId = StringConverter.toString(act.getId());
this.comment = (info == null) ? null : info.getComment();
this.selected = Boolean.valueOf(info != null);
}
 
public String getActId()
{
return actId;
}
 
public void setActId(String actId)
{
this.actId = actId;
}
 
public String getComment()
{
return comment;
}
 
public void setComment(String comment)
{
this.comment = comment;
}
 
public Boolean getSelected()
{
return selected;
}
 
public void setSelected(Boolean selected)
{
this.selected = selected;
}
}