示例#1
0
 public List<String> getEmailsForReplies() {
   return new SafeHibList<String>(
           HibernateUtil.currentSession()
               .createSQLQuery(
                   "SELECT DISTINCT u.email FROM users u, flaggedposts p WHERE u.repliesasemails = 0b1 AND u.id = p.userid AND p.postid = :pid")
               .setInteger("pid", getId()))
       .list();
 }
  public static ConferenceRegistrationModel newRegistration(
      UserModel user,
      String type,
      int prevConfs,
      int prevRetreats,
      boolean headset,
      String foodPrefs,
      String emergName,
      String emergPhone,
      String specialNeeds,
      String code,
      String receiptNum,
      boolean africafund) {
    ConferenceRegistrationModel reg = new ConferenceRegistrationModel();
    reg.setUser(user);
    reg.setType(type);
    reg.setDate(new Date());
    reg.setReceiptNum(receiptNum);
    reg.setAmountPaid(costs.get(type));
    reg.setChapter(user.getChapter());
    reg.setSubsidized(type.contains("sub"));

    reg.setCancelled(false);

    if (type.contains("reg0")) reg.setRoomSize(0);
    if (type.contains("reg1")) reg.setRoomSize(1);
    if (type.contains("reg2")) reg.setRoomSize(2);
    if (type.contains("reg4")) reg.setRoomSize(4);

    reg.setEmergName(emergName);
    reg.setEmergPhone(emergPhone);
    reg.setSpecialNeeds(specialNeeds);
    reg.setHeadset(headset);
    reg.setFoodPrefs(foodPrefs);
    reg.setPrevConfs(prevConfs);
    reg.setPrevRetreats(prevRetreats);
    reg.setCode(code);

    reg.setAfricafund(africafund);

    HibernateUtil.currentSession().save(reg);
    return reg;
  }
示例#3
0
  public PostModel reply(UserModel currentUser, String body, String tags) {
    if (!hasActiveWhiteboard()) {
      Session hibernateSession = HibernateUtil.currentSession();
      PostModel p = new PostModel();
      hibernateSession.save(p);
      AjaxServlet.invalidateFrontPageCache(getGroup().getId());

      p.setBody(body);
      addReply(p); // sets group on reply

      Logger.getLogger(this.getClass())
          .info("Post " + this.getId() + " has " + this.getReplies().size() + " replies.");

      if (this.getReplies().size() == Post.RepliesToFeature) {
        this.feature();
      }

      if (this.isFeatured()) {
        p.feature();
      }

      for (String tag : TagLogic.extractTagNames(tags)) {
        addTag(TagModel.getOrCreateTag(tag));
      }

      currentUser.addPost(p);

      setLastReply(new Date());

      hibernateSession.flush();
      Helpers.currentDailyStats().logReply();

      p.setSearchable(SearchableModel.newSearchable(p, null, null));

      return p;
    } else {
      Logger.getLogger(this.getClass()).debug("Tried to reply to a post that has a whiteboard.");
      return null;
    }
  }
示例#4
0
  public static PostModel newPost(
      UserModel currentUser,
      GroupModel targetGroup,
      String subject,
      String intro,
      String body,
      String unsplitTags,
      boolean whiteboard) {
    Session hibernateSession = HibernateUtil.currentSession();
    PostModel p = new PostModel();
    hibernateSession.save(p);
    AjaxServlet.invalidateFrontPageCache(targetGroup.getId());

    p.setSubject(subject);
    p.setIntro(intro);

    if (!body.trim().equals("")) {
      p.setBody(body);
    }

    targetGroup.addPost(p);

    for (String tag : TagLogic.extractTagNames(unsplitTags)) {
      p.addTag(TagModel.getOrCreateTag(tag));
    }

    currentUser.addPost(p);

    hibernateSession.flush();

    if (whiteboard) {
      p.setWhiteboard(WhiteboardModel.newWhiteboard(null, p, null));
    }
    Helpers.currentDailyStats().logPost();

    p.setSearchable(SearchableModel.newSearchable(p, null, null));

    return p;
  }
示例#5
0
 public static Date getLatestReplyDate() {
   String sql = " SELECT max(`lastReply`) FROM posts ";
   return (Date) HibernateUtil.currentSession().createSQLQuery(sql).uniqueResult();
 }