Search in sources :

Example 1 with PrivateMessage

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;
}
Also used : LocalDateTime(java.time.LocalDateTime) User(org.apache.openmeetings.db.entity.user.User) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage)

Example 2 with PrivateMessage

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();
}
Also used : WysiwygEditor(com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) DefaultWysiwygToolbar(com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.DefaultWysiwygToolbar) UserMultiChoice(org.apache.openmeetings.web.util.UserMultiChoice) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) RoomTypeDropDown(org.apache.openmeetings.web.util.RoomTypeDropDown) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage)

Example 3 with PrivateMessage

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);
        }
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) ArrayList(java.util.ArrayList) Invitation(org.apache.openmeetings.db.entity.room.Invitation) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Room(org.apache.openmeetings.db.entity.room.Room) Date(java.util.Date)

Example 4 with PrivateMessage

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);
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) RoomEnterBehavior(org.apache.openmeetings.web.user.rooms.RoomEnterBehavior) Button(org.apache.wicket.markup.html.form.Button) Label(org.apache.wicket.markup.html.basic.Label) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Room(org.apache.openmeetings.db.entity.room.Room)

Example 5 with PrivateMessage

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);
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RoomConverter(org.apache.openmeetings.backup.converter.RoomConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Serializer(org.simpleframework.xml.Serializer)

Aggregations

PrivateMessage (org.apache.openmeetings.db.entity.user.PrivateMessage)8 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)2 Date (java.util.Date)2 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)2 Room (org.apache.openmeetings.db.entity.room.Room)2 User (org.apache.openmeetings.db.entity.user.User)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 Serializer (org.simpleframework.xml.Serializer)2 Registry (org.simpleframework.xml.convert.Registry)2 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)2 Persister (org.simpleframework.xml.core.Persister)2 Strategy (org.simpleframework.xml.strategy.Strategy)2 WysiwygEditor (com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor)1 DefaultWysiwygToolbar (com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.DefaultWysiwygToolbar)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 RoomConverter (org.apache.openmeetings.backup.converter.RoomConverter)1 UserConverter (org.apache.openmeetings.backup.converter.UserConverter)1 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)1 Invitation (org.apache.openmeetings.db.entity.room.Invitation)1