Package org.apache.openmeetings.db.entity.user

Examples of org.apache.openmeetings.db.entity.user.PrivateMessage


    target.add(feedback);
  }

  @Override
  protected void onSubmit(AjaxRequestTarget target) {
    PrivateMessage p = getModelObject();
    p.setInserted(new Date());
    if (p.isBookedRoom()) {
      Room r = p.getRoom();
      r.setName(p.getSubject());
      r.setComment("");
      r.setNumberOfPartizipants(100L);
      r.setAppointment(true);
      r.setAllowUserQuestions(true);
      r.setAllowFontStyles(true);
      getBean(RoomDao.class).update(r, getUserId());
    } else {
      p.setRoom(null);
    }
    PrivateMessagesDao msgDao = getBean(PrivateMessagesDao.class);
    for (User to : modelTo.getObject()) {
      if (to.getUser_id() == null) {
        getBean(UserDao.class).update(to, getUserId());
      }
      //to send
      p = new PrivateMessage(p);
      p.setTo(to);
      p.setFolderId(SENT_FOLDER_ID);
      msgDao.update(p, getUserId());
      //to inbox
      p = new PrivateMessage(p);
      p.setOwner(to);
      p.setFolderId(INBOX_FOLDER_ID);
      msgDao.update(p, getUserId());
      if (to.getAdresses() != null) {
        String aLinkHTML =   isPrivate ? "<br/><br/>" + "<a href='" + ContactsHelper.getLink() + "'>"
              + WebSession.getString(1302) + "</a><br/>" : "";
       
        getBean(MailHandler.class).send(to.getAdresses().getEmail(),
            WebSession.getString(1301) + p.getSubject(),
            (p.getMessage() == null ? "" : p.getMessage().replaceAll("\\<.*?>", "")) + aLinkHTML);
      }
    }
  }
View Full Code Here


            refresh(target);
          }
        });
      }
    });
    add(newMessage = new MessageDialog("newMessage", new CompoundPropertyModel<PrivateMessage>(new PrivateMessage())) {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClose(AjaxRequestTarget target, DialogButton button) {
        if (send.equals(button)) {
View Full Code Here

 
  public MessageDialog reset(boolean isPrivate) {
    modelStart.setObject(new Date());
    modelEnd.setObject(new Date()); //TODO should we add 1 hour or generalize with Calendar???
    modelTo.setObject(new ArrayList<User>());
    PrivateMessage p = new PrivateMessage();
    p.setFrom(getBean(UserDao.class).get(getUserId()));
    p.setOwner(p.getFrom());
    p.setIsRead(false);
    p.setFolderId(INBOX_FOLDER_ID);
    Room r = new Room();
    r.setAppointment(true);
    r.setRoomtype(getRoomTypes().get(0));
    p.setRoom(r);
    setModelObject(p);
    roomParams.setVisible(getModelObject().isBookedRoom());
    form.setModelObject(p);
    this.isPrivate = isPrivate;
    return this;
View Full Code Here

  private String getEmail(User u) {
    return u == null || u.getAdresses() == null ? "" : u.getAdresses().getEmail();
  }
 
  private void selectMessage(long id, AjaxRequestTarget target) {
    PrivateMessage msg = getBean(PrivateMessagesDao.class).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 (target != null) {
      target.add(selectedMessage);
      updateControls(target);
    }
  }
View Full Code Here

    super(id);
    NOT_MOVE_FOLDER.setPrivateMessageFolderId(MOVE_CHOOSE);
    NOT_MOVE_FOLDER.setFolderName(WebSession.getString(1243));
    foldersModel = Model.ofList(getBean(PrivateMessageFolderDao.class).get(0, Integer.MAX_VALUE));
    updateMoveModel();
    add(newMessage = new MessageDialog("newMessage", new CompoundPropertyModel<PrivateMessage>(new PrivateMessage())) {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClose(AjaxRequestTarget target, DialogButton button) {
        if (send.equals(button)) {
          target.add(container);
        }
      }
    });
   
    final AddFolderDialog addFolder = new AddFolderDialog("addFolder") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onSubmit(AjaxRequestTarget target) {
        super.onSubmit(target);
        PrivateMessageFolderDao fDao = getBean(PrivateMessageFolderDao.class);
        fDao.addPrivateMessageFolder(getModelObject(), getUserId());
        foldersModel.setObject(fDao.get(0, Integer.MAX_VALUE));
        updateMoveModel();
        target.add(folders, moveDropDown);
      }
    };
    add(addFolder);
    add(new WebMarkupContainer("new").add(new AjaxEventBehavior("click") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onEvent(AjaxRequestTarget target) {
        newMessage.reset(true).open(target);
      }
    }).add(new JQueryBehavior(".email.new", "button")));
    folders.add(inbox.add(new AjaxEventBehavior("click") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onEvent(AjaxRequestTarget target) {
        selectFolder(inbox, INBOX_FOLDER_ID, target);
      }
    }));
    folders.add(sent.add(new AjaxEventBehavior("click") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onEvent(AjaxRequestTarget target) {
        selectFolder(sent, SENT_FOLDER_ID, target);
      }
    }));
    folders.add(trash.add(new AjaxEventBehavior("click") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onEvent(AjaxRequestTarget target) {
        selectFolder(trash, TRASH_FOLDER_ID, target);
      }
    }));
    folders.add(new WebMarkupContainer("newdir").add(new AjaxEventBehavior("click") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onEvent(AjaxRequestTarget target) {
        addFolder.open(target);
      }
    }).add(new JQueryBehavior(".email.newdir", "button")));
    add(folders.add(new ListView<PrivateMessageFolder>("folder", foldersModel) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void populateItem(final ListItem<PrivateMessageFolder> item) {
        item.add(new Label("name", item.getModelObject().getFolderName()));
        item.add(new WebMarkupContainer("delete").add(new AjaxEventBehavior("click") {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onEvent(AjaxRequestTarget target) {
            PrivateMessageFolderDao fDao = getBean(PrivateMessageFolderDao.class);
            fDao.delete(item.getModelObject(), getUserId());
            foldersModel.setObject(fDao.get(0, Integer.MAX_VALUE));
            target.add(folders);
          }
         
          @Override
          protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new ConfirmAjaxCallListener(WebSession.getString(713)));
          }
        }));
        item.add(new AjaxEventBehavior("click") {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onEvent(AjaxRequestTarget target) {
            selectFolder(item, item.getModelObject().getPrivateMessageFolderId(), target);
          }
        });
        setFolderClass(item);
      }
    }).setOutputMarkupId(true));
   
    SearchableDataProvider<PrivateMessage> sdp = new SearchableDataProvider<PrivateMessage>(PrivateMessagesDao.class) {
      private static final long serialVersionUID = 1L;

      @Override
      protected PrivateMessagesDao getDao() {
        return (PrivateMessagesDao)super.getDao();
      }
     
      @Override
      public Iterator<? extends PrivateMessage> iterator(long first, long count) {
        allMessages.clear();
        readMessages.clear();
        unreadMessages.clear();
        String sort = getSort() == null ? "" : "m." + getSort().getProperty();
        boolean isAsc = getSort() == null ? true : getSort().isAscending();
        return getDao().get(getUserId(), selectedFolderModel.getObject(), search, sort, isAsc, (int)first, (int)count).iterator();
      }
     
      @Override
      public long size() {
        return getDao().count(getUserId(), selectedFolderModel.getObject(), search);
      }
    };
    final SearchableDataView<PrivateMessage> dv = new SearchableDataView<PrivateMessage>("messages", sdp) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void populateItem(Item<PrivateMessage> item) {
        PrivateMessage m = item.getModelObject();
        final long id = m.getId();
        allMessages.add(id);
        if (m.getIsRead()) {
          readMessages.add(id);
        } else {
          unreadMessages.add(id);
        }
        item.add(new Label("id", id));
        item.add(new Label("from", getDisplayName(m.getFrom())));
        item.add(new Label("subject", m.getSubject()));
        item.add(new Label("send", getDateFormat().format(m.getInserted())));
        item.add(new AjaxEventBehavior("click") {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onEvent(AjaxRequestTarget target) {
            long selected = id;
            if (selectedMessages.contains(id)) {
              selectedMessages.remove(id);
              selected = selectedMessages.isEmpty() ? -1 : selectedMessages.iterator().next();
            } else {
              selectedMessages.add(id);
            }
            selectMessage(selected, target);
            target.add(container);
          }
        });
        StringBuilder cssClass = new StringBuilder(Boolean.FALSE.equals(m.getIsRead()) ? "unread" : "");
        if (selectedMessages.contains(id)) {
          if (cssClass.length() > 0) {
            cssClass.append(" ");
          }
          cssClass.append("ui-state-active");
View Full Code Here

TOP

Related Classes of org.apache.openmeetings.db.entity.user.PrivateMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.