if (days < 10) {
// Week or day view:
longFormat = true;
}
final TeamCalRight right = new TeamCalRight();
final PFUserDO user = PFUserContext.getUser();
final TimeZone timeZone = PFUserContext.getTimeZone();
if (CollectionUtils.isNotEmpty(teamEvents) == true) {
for (final TeamEvent teamEvent : teamEvents) {
final DateTime startDate = new DateTime(teamEvent.getStartDate(), PFUserContext.getDateTimeZone());
final DateTime endDate = new DateTime(teamEvent.getEndDate(), PFUserContext.getDateTimeZone());
final TeamEventDO eventDO;
final TeamCalEventId id = new TeamCalEventId(teamEvent, timeZone);
if (teamEvent instanceof TeamEventDO) {
eventDO = (TeamEventDO) teamEvent;
} else {
eventDO = ((TeamRecurrenceEvent) teamEvent).getMaster();
}
teamEventMap.put(id.toString(), teamEvent);
final MyEvent event = new MyEvent();
event.setClassName(EVENT_CLASS_NAME + " " + EventDroppedCallbackScriptGenerator.NO_CONTEXTMENU_INDICATOR);
event.setId("" + id);
event.setColor(activeTemplateEntry.getColorCode(eventDO.getCalendarId()));
if (eventRight.hasUpdateAccess(PFUserContext.getUser(), eventDO, null)) {
event.setEditable(true);
} else {
event.setEditable(false);
}
// id <= 0 is hint for abo events -> not editable
if(eventDO.getId() != null && eventDO.getId() <= 0) {
event.setEditable(false);
}
if (teamEvent.isAllDay() == true) {
event.setAllDay(true);
}
event.setStart(startDate);
event.setEnd(endDate);
String recurrence = null;
if (eventDO.hasRecurrence() == true) {
final Recur recur = eventDO.getRecurrenceObject();
final TeamEventRecurrenceData recurrenceData = new TeamEventRecurrenceData(recur, PFUserContext.getTimeZone());
final RecurrenceFrequency frequency = recurrenceData.getFrequency();
if (frequency != null) {
final String unitI18nKey = frequency.getUnitI18nKey();
if (unitI18nKey != null) {
recurrence = recurrenceData.getInterval() + " " + getString(unitI18nKey);
}
}
}
String reminder = null;
if (eventDO.getReminderActionType() != null
&& NumberHelper.greaterZero(eventDO.getReminderDuration()) == true
&& eventDO.getReminderDurationUnit() != null) {
reminder = getString(eventDO.getReminderActionType().getI18nKey())
+ " "
+ eventDO.getReminderDuration()
+ " "
+ getString(eventDO.getReminderDurationUnit().getI18nKey());
}
event.setTooltip(eventDO.getCalendar().getTitle(), new String[][] { { eventDO.getSubject()},
{ eventDO.getLocation(), getString("timesheet.location")}, { eventDO.getNote(), getString("plugins.teamcal.event.note")},
{ recurrence, getString("plugins.teamcal.event.recurrence")}, { reminder, getString("plugins.teamcal.event.reminder")}});
final String title;
String durationString = "";
if (longFormat == true) {
// String day = duration.getDays() + "";
final Period period = new Period(startDate, endDate);
int hourInt = period.getHours();
if (period.getDays() > 0) {
hourInt += period.getDays() * 24;
}
final String hour = hourInt < 10 ? "0" + hourInt : "" + hourInt;
final int minuteInt = period.getMinutes();
final String minute = minuteInt < 10 ? "0" + minuteInt : "" + minuteInt;
if (event.isAllDay() == false) {
durationString = "\n" + PFUserContext.getLocalizedString("plugins.teamcal.event.duration") + ": " + hour + ":" + minute;
}
final StringBuffer buf = new StringBuffer();
buf.append(teamEvent.getSubject());
if (StringUtils.isNotBlank(teamEvent.getNote()) == true) {
buf.append("\n").append(PFUserContext.getLocalizedString("plugins.teamcal.event.note")).append(": ")
.append(teamEvent.getNote());
}
buf.append(durationString);
title = buf.toString();
} else {
title = teamEvent.getSubject();
}
if (right.hasMinimalAccess(eventDO.getCalendar(), user.getId()) == true) {
// for minimal access
event.setTitle("");
event.setEditable(false);
} else {
event.setTitle(title);