Package ru.org.linux.site

Examples of ru.org.linux.site.Template


  public RedirectView moveTopic(
    ServletRequest request,
    @RequestParam int msgid,
    @RequestParam("moveto") int newgr
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not moderator");
    }

    Topic msg = messageDao.getById(msgid);

    if (msg.isDeleted()) {
      throw new AccessViolationException("Сообщение удалено");
    }

    Group newGrp = groupDao.getGroup(newgr);

    if (msg.getGroupId()!=newGrp.getId()) {
      messageDao.moveTopic(msg, newGrp, tmpl.getCurrentUser());
    }

    return new RedirectView(TopicLinkBuilder.baseLink(msg).forceLastmod().build());
  }
View Full Code Here


  @RequestMapping(value="/mt.jsp", method=RequestMethod.GET)
  public ModelAndView moveTopicFormForum(
    ServletRequest request,
    @RequestParam int msgid
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not authorized");
    }

    ModelAndView mv = new ModelAndView("mtn");
View Full Code Here

  @RequestMapping(value="/mtn.jsp", method=RequestMethod.GET)
  public ModelAndView moveTopicForm(
          ServletRequest request,
          @RequestParam int msgid
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not authorized");
    }

    ModelAndView mv = new ModelAndView("mtn");
View Full Code Here

  @RequestMapping(value = "/uncommit.jsp", method = RequestMethod.GET)
  public ModelAndView uncommitForm(
    HttpServletRequest request,
    @RequestParam int msgid
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not authorized");
    }

    Topic message = messageDao.getById(msgid);

    checkUncommitable(message);

    ModelAndView mv = new ModelAndView("uncommit");
    mv.getModel().put("message", message);
    mv.getModel().put("preparedMessage", prepareService.prepareTopic(message, request.isSecure(), tmpl.getCurrentUser()));

    return mv;
  }
View Full Code Here

  @RequestMapping(value="/uncommit.jsp", method=RequestMethod.POST)
  public ModelAndView uncommit(
    HttpServletRequest request,
    @RequestParam int msgid
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not authorized");
    }

    Topic message = messageDao.getById(msgid);

    checkUncommitable(message);

    messageDao.uncommit(message);

    logger.info("Отменено подтверждение сообщения " + msgid + " пользователем " + tmpl.getNick());

    return new ModelAndView("action-done", "message", "Подтверждение отменено");
  }
View Full Code Here

                            @RequestParam("ip") String ip,
                            @RequestParam("time") String time
                            ) throws Exception {
    Map<String, Object> params = new HashMap<>();

    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not moderator");
    }

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    if ("hour".equals(time)) {
      calendar.add(Calendar.HOUR_OF_DAY, -1);
    } else if ("day".equals(time)) {
      calendar.add(Calendar.DAY_OF_MONTH, -1);
    } else if ("3day".equals(time)) {
      calendar.add(Calendar.DAY_OF_MONTH, -3);
    } else {
      throw new UserErrorException("Invalid count");
    }

    Timestamp ts = new Timestamp(calendar.getTimeInMillis());
    params.put("message", "Удаляем темы и сообщения после "+ts.toString()+" с IP "+ip+"<br>");

    User moderator = tmpl.getCurrentUser();

    DeleteCommentResult deleteResult = commentService.deleteCommentsByIPAddress(ip, ts, moderator, reason);

    params.put("topics", deleteResult.getDeletedTopicIds().size()); // кол-во удаленных топиков
    params.put("deleted", deleteResult.getDeleteInfo());
View Full Code Here

  @RequestMapping("/sameip.jsp")
  public ModelAndView sameIP(
    HttpServletRequest request,
    @RequestParam(required = false) Integer msgid
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not moderator");
    }

    String ip;
View Full Code Here

    return filtred.build();
  }

  @RequestMapping({"/", "/index.jsp"})
  public ModelAndView mainPage(HttpServletRequest request, HttpServletResponse response) {
    Template tmpl = Template.getTemplate(request);

    response.setDateHeader("Expires", System.currentTimeMillis() - 20 * 3600 * 1000);
    response.setDateHeader("Last-Modified", System.currentTimeMillis() - 2 * 1000);

    List<Topic> messages = topicListService.getMainPageFeed(tmpl.getProf().isShowGalleryOnMain());

    ModelAndView mv = new ModelAndView("index");

    Profile profile = tmpl.getProf();

    mv.getModel().put("news", prepareService.prepareMessagesForUser(
            profile.isMiniNewsBoxletOnMainPage() ? filterMiniNews(messages) : messages,
            request.isSecure(),
            tmpl.getCurrentUser(),
            profile,
            false
    ));
 
    if (tmpl.isSessionAuthorized()) {
      mv.getModel().put("hasDrafts", topicDao.hasDrafts(tmpl.getCurrentUser()));
      mv.getModel().put("favPresent", memoriesDao.isFavPresetForUser(tmpl.getCurrentUser()));
    }

    if (tmpl.isModeratorSession() || tmpl.isCorrectorSession()) {
      int uncommited = topicDao.getUncommitedCount();

      mv.getModel().put("uncommited", uncommited);

      int uncommitedNews = 0;

      if (uncommited > 0) {
        uncommitedNews = topicDao.getUncommitedCount(Section.SECTION_NEWS);
      }

      mv.getModel().put("uncommitedNews", uncommitedNews);
    }

    mv.getModel().put("showAdsense", !tmpl.isSessionAuthorized() || !tmpl.getProf().isHideAdsense());

    return mv;
  }
View Full Code Here

TOP

Related Classes of ru.org.linux.site.Template

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.