Пример #1
0
    public void execute(Event<UIVoteQuestion> event) throws Exception {
      UIVoteQuestion voteQuestion = event.getSource();
      int number = Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID));
      String currentUser = FAQUtils.getCurrentUser();
      List<String> listUsers = new ArrayList<String>();

      if (voteQuestion.question_.getUsersVote() != null) {
        listUsers.addAll(Arrays.asList(voteQuestion.question_.getUsersVote()));
      }
      long totalVote = listUsers.size();
      double markVote =
          (voteQuestion.question_.getMarkVote() * totalVote + number) / (totalVote + 1);

      listUsers.add(currentUser + "/" + number);
      voteQuestion.question_.setMarkVote(markVote);
      voteQuestion.question_.setUsersVote(listUsers.toArray(new String[] {}));
      FAQService faqService_ =
          (FAQService) PortalContainer.getInstance().getComponentInstanceOfType(FAQService.class);
      FAQUtils.getEmailSetting(voteQuestion.faqSetting_, false, false);
      faqService_.saveQuestion(voteQuestion.question_, false, voteQuestion.faqSetting_);
      UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
      UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
      UIQuestions questions =
          portlet.getChild(UIAnswersContainer.class).getChild(UIQuestions.class);
      // questions.setIsNotChangeLanguage() ;
      event.getRequestContext().addUIComponentToUpdateByAjax(questions);
      popupAction.deActivate();
      event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
    }
Пример #2
0
 public void execute(Event<UIVoteQuestion> event) throws Exception {
   UIVoteQuestion voteQuestion = event.getSource();
   double markVote = Double.parseDouble(event.getRequestContext().getRequestParameter(OBJECTID));
   FAQService faqService_ =
       (FAQService) PortalContainer.getInstance().getComponentInstanceOfType(FAQService.class);
   Answer answer = null;
   if (voteQuestion.language_ != null
       && voteQuestion.language_.trim().length() > 0
       && !voteQuestion.language_.equals(voteQuestion.question_.getLanguage())) {
     answer =
         faqService_.getAnswerById(
             voteQuestion.question_.getPath(), voteQuestion.answerId_, voteQuestion.language_);
     answer.setMarksVoteAnswer(markVote);
     faqService_.saveAnswer(voteQuestion.question_.getPath(), answer, voteQuestion.language_);
   } else {
     answer =
         faqService_.getAnswerById(voteQuestion.question_.getPath(), voteQuestion.answerId_);
     answer.setMarksVoteAnswer(markVote);
     faqService_.saveAnswer(voteQuestion.question_.getPath(), answer, false);
   }
   UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
   UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
   UIQuestions questions =
       portlet.getChild(UIAnswersContainer.class).getChild(UIQuestions.class);
   // questions.setIsNotChangeLanguage() ;
   event.getRequestContext().addUIComponentToUpdateByAjax(questions);
   popupAction.deActivate();
   event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
 }
Пример #3
0
 public void execute(Event<UIVoteQuestion> event) throws Exception {
   UIVoteQuestion voteQuestion = event.getSource();
   UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
   UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
   popupAction.deActivate();
   event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
 }
Пример #4
0
 public void onEvent(
     Event<UIModerationForum> event, UIModerationForum moderationForum, final String objectId)
     throws Exception {
   ForumSearch forumSearch = moderationForum.getObject(objectId);
   UIPopupContainer popupContainer = moderationForum.getAncestorOfType(UIPopupContainer.class);
   UIPopupAction popupAction = popupContainer.getChild(UIPopupAction.class);
   if (forumSearch.getType().equals(Utils.TOPIC)) {
     try {
       Topic topic =
           moderationForum.getForumService().getTopicByPath(forumSearch.getPath(), false);
       UIViewTopic viewTopic = popupAction.activate(UIViewTopic.class, 700);
       viewTopic.setTopic(topic);
       viewTopic.setActionForm(new String[] {"Approve", "DeleteTopic", "Close"});
       event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
     } catch (Exception e) {
       moderationForum.log.warn("Failed to view topic: ", e);
     }
   } else {
     try {
       Post post =
           moderationForum
               .getForumService()
               .getPost(
                   ForumUtils.EMPTY_STR,
                   ForumUtils.EMPTY_STR,
                   ForumUtils.EMPTY_STR,
                   forumSearch.getPath());
       UIViewPost viewPost = popupAction.activate(UIViewPost.class, 700);
       viewPost.setPostView(post);
       viewPost.setViewUserInfo(false);
       viewPost.setActionForm(new String[] {"Approve", "DeletePost", "Close", "OpenTopicLink"});
       event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
     } catch (Exception e) {
       moderationForum.log.warn("Failed to view post: ", e);
     }
   }
 }