use of org.apache.openmeetings.db.entity.user.PrivateMessage in project openmeetings by apache.
the class MessageDialog method reset.
public MessageDialog reset(boolean isPrivate) {
LocalDateTime now = ZonedDateTime.now(getZoneId()).toLocalDateTime();
start.setModelObject(now);
end.setModelObject(now.plus(1, ChronoUnit.HOURS));
modelTo.setObject(new ArrayList<User>());
PrivateMessage p = new PrivateMessage();
p.setFrom(userDao.get(getUserId()));
p.setOwner(p.getFrom());
p.setIsRead(false);
p.setFolderId(INBOX_FOLDER_ID);
p.setRoom(AppointmentDialog.createAppRoom());
setModelObject(p);
roomParams.setVisible(getModelObject().isBookedRoom());
form.setModelObject(p);
this.isPrivate = isPrivate;
return this;
}
use of org.apache.openmeetings.db.entity.user.PrivateMessage in project openmeetings by apache.
the class MessageDialog method onInitialize.
@Override
protected void onInitialize() {
getTitle().setObject(getString("1209"));
send = new DialogButton("send", getString("218"));
cancel = new DialogButton("cancel", getString("lbl.cancel"));
form.add(feedback.setOutputMarkupId(true));
form.add(new UserMultiChoice("to", modelTo).setRequired(true));
form.add(new TextField<String>("subject"));
DefaultWysiwygToolbar toolbar = new DefaultWysiwygToolbar("toolbarContainer");
form.add(toolbar);
form.add(new WysiwygEditor("message", toolbar));
form.add(roomParamsBlock.setOutputMarkupId(true));
final CheckBox bookedRoom = new CheckBox("bookedRoom");
form.add(bookedRoom.setOutputMarkupId(true).add(new AjaxEventBehavior(EVT_CLICK) {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
PrivateMessage p = MessageDialog.this.getModelObject();
p.setBookedRoom(!p.isBookedRoom());
roomParams.setVisible(p.isBookedRoom());
target.add(bookedRoom, roomParamsBlock);
}
}));
bookedRoom.setVisible(cfgDao.getBool(CONFIG_MYROOMS_ENABLED, true));
roomParamsBlock.add(roomParams);
roomParams.add(new RoomTypeDropDown("room.type"));
roomParams.add(start);
roomParams.add(end);
add(form.setOutputMarkupId(true));
super.onInitialize();
}
use of org.apache.openmeetings.db.entity.user.PrivateMessage in project openmeetings by apache.
the class MessageDialog method onSubmit.
@Override
protected void onSubmit(AjaxRequestTarget target) {
PrivateMessage m = getModelObject();
m.setInserted(new Date());
User owner = userDao.get(getUserId());
if (m.isBookedRoom()) {
Room r = m.getRoom();
r.setName(m.getSubject());
r.setComment("");
r.setCapacity(100L);
r.setAppointment(true);
r.setAllowUserQuestions(true);
r = roomDao.update(r, getUserId());
Appointment a = new Appointment();
a.setTitle(m.getSubject());
a.setDescription(m.getMessage());
a.setRoom(r);
a.setStart(CalendarWebHelper.getDate(start.getModelObject()));
a.setEnd(CalendarWebHelper.getDate(end.getModelObject()));
List<MeetingMember> attendees = new ArrayList<>();
for (User to : modelTo.getObject()) {
MeetingMember mm = new MeetingMember();
mm.setUser(to);
mm.setDeleted(false);
mm.setInserted(a.getInserted());
mm.setUpdated(a.getUpdated());
mm.setAppointment(a);
attendees.add(mm);
}
a.setOwner(owner);
a.setMeetingMembers(attendees);
apptDao.update(a, getUserId(), false);
m.setRoom(r);
} else {
m.setRoom(null);
}
for (User to : modelTo.getObject()) {
if (to.getId() == null) {
userDao.update(to, getUserId());
}
// to send
PrivateMessage p = new PrivateMessage(m);
p.setTo(to);
p.setFolderId(SENT_FOLDER_ID);
msgDao.update(p, getUserId());
// to inbox
p = new PrivateMessage(m);
p.setOwner(to);
p.setFolderId(INBOX_FOLDER_ID);
msgDao.update(p, getUserId());
if (to.getAddress() != null) {
String aLinkHTML = (isPrivate && to.getType() == Type.user) ? "<br/><br/>" + "<a href='" + getContactsLink() + "'>" + Application.getString("1302", to.getLanguageId()) + "</a><br/>" : "";
String invitationLink = "";
if (p.isBookedRoom()) {
Invitation i = inviteManager.getInvitation(to, p.getRoom(), false, null, Valid.Period, owner, to.getLanguageId(), CalendarHelper.getDate(start.getModelObject(), to.getTimeZoneId()), CalendarHelper.getDate(end.getModelObject(), to.getTimeZoneId()), null);
invitationLink = getInvitationLink(i, WebSession.get().getExtendedProperties().getBaseUrl());
if (invitationLink == null) {
invitationLink = "";
} else {
invitationLink = //
"<br/>" + Application.getString("503", to.getLanguageId()) + "<br/><a href='" + invitationLink + "'>" + Application.getString("504", to.getLanguageId()) + "</a><br/>";
}
}
String subj = p.getSubject() == null ? "" : p.getSubject();
handler.send(to.getAddress().getEmail(), Application.getString("1301", to.getLanguageId()) + subj, (p.getMessage() == null ? "" : p.getMessage().replaceAll("\\<.*?>", "")) + aLinkHTML + invitationLink);
}
}
}
use of org.apache.openmeetings.db.entity.user.PrivateMessage in project openmeetings by apache.
the class MessagesContactsPanel method selectMessage.
private void selectMessage(long id, AjaxRequestTarget target) {
PrivateMessage msg = msgDao.get(id);
selectedMessage.addOrReplace(new Label("from", msg == null ? "" : getEmail(msg.getFrom())));
selectedMessage.addOrReplace(new Label("to", msg == null ? "" : getEmail(msg.getTo())));
selectedMessage.addOrReplace(new Label("subj", msg == null ? "" : msg.getSubject()));
selectedMessage.addOrReplace(new Label("body", msg == null ? "" : msg.getMessage()).setEscapeModelStrings(false));
if (msg != null) {
Room r = msg.getRoom();
if (r != null) {
Appointment a = apptDao.getByRoom(r.getId());
roomContainer.addOrReplace(new Label("start", a == null ? "" : getDateFormat().format(a.getStart())));
roomContainer.addOrReplace(new Label("end", a == null ? "" : getDateFormat().format(a.getEnd())));
roomContainer.addOrReplace(new Button("enter").add(new RoomEnterBehavior(r.getId())));
}
roomContainer.setVisible(r != null);
}
if (target != null) {
target.add(selectedMessage);
updateControls(target);
}
}
use of org.apache.openmeetings.db.entity.user.PrivateMessage in project openmeetings by apache.
the class BackupImport method importPrivateMsgs.
/*
* ##################### Import Private Messages
*/
private void importPrivateMsgs(File f) throws Exception {
log.info("Usercontact import complete, starting private messages item import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(User.class, new UserConverter(userDao, userMap));
registry.bind(Room.class, new RoomConverter(roomDao, roomMap));
registry.bind(Date.class, DateConverter.class);
List<PrivateMessage> list = readList(serializer, f, "privateMessages.xml", "privatemessages", PrivateMessage.class);
boolean oldBackup = true;
for (PrivateMessage p : list) {
if (p.getFolderId() == null || p.getFolderId().longValue() < 0) {
oldBackup = false;
break;
}
}
for (PrivateMessage p : list) {
p.setId(null);
p.setFolderId(messageFolderMap.get(p.getFolderId()));
p.setUserContactId(userContactMap.get(p.getUserContactId()));
if (p.getRoom() != null && p.getRoom().getId() == null) {
p.setRoom(null);
}
if (p.getTo() != null && p.getTo().getId() == null) {
p.setTo(null);
}
if (p.getFrom() != null && p.getFrom().getId() == null) {
p.setFrom(null);
}
if (p.getOwner() != null && p.getOwner().getId() == null) {
p.setOwner(null);
}
if (oldBackup && p.getOwner() != null && p.getOwner().getId() != null && p.getFrom() != null && p.getFrom().getId() != null && p.getOwner().getId() == p.getFrom().getId()) {
p.setFolderId(SENT_FOLDER_ID);
}
privateMessageDao.update(p, null);
}
}
Aggregations