Package ru.org.linux.site

Examples of ru.org.linux.site.Template


  @RequestMapping(value = "/add.jsp", method = RequestMethod.GET)
  public ModelAndView add(
          @Valid @ModelAttribute("form") AddTopicRequest form,
          HttpServletRequest request
  ) {
    Template tmpl = Template.getTemplate(request);

    if (form.getMode()==null) {
      form.setMode(tmpl.getFormatMode());
    }

    Map<String, Object> params = new HashMap<>();
    params.putAll(prepareModel(form, tmpl.getCurrentUser()));

    Group group = form.getGroup();

    if (tmpl.isSessionAuthorized() && !groupPermissionService.isTopicPostingAllowed(group, tmpl.getCurrentUser())) {
      ModelAndView errorView = new ModelAndView("errors/good-penguin");
      errorView.addObject("msgHeader", "Недостаточно прав для постинга тем в эту группу");
      errorView.addObject("msgMessage", groupPermissionService.getPostScoreInfo(group));

      return errorView;
View Full Code Here


          HttpServletRequest request,
          @Valid @ModelAttribute("form") AddTopicRequest form,
          BindingResult errors,
          @ModelAttribute("ipBlockInfo") IPBlockInfo ipBlockInfo
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);
    HttpSession session = request.getSession();

    String image = processUploadImage(request);

    Group group = form.getGroup();

    Map<String, Object> params = new HashMap<>();

    params.putAll(prepareModel(form, tmpl.getCurrentUser()));

    Section section = null;

    if (group!=null) {
      section = sectionService.getSection(group.getSectionId());
    }

    User user = postingUser(tmpl, form);

    user.checkBlocked(errors);

    IPBlockDao.checkBlockIP(ipBlockInfo, errors, user);

    if (group!=null && !groupPermissionService.isTopicPostingAllowed(group, user)) {
      errors.reject(null, "Недостаточно прав для постинга тем в эту группу");
    }

    String message = processMessage(form.getMsg(), form.getMode());

    if (user.isAnonymous()) {
      if (message.length() > MAX_MESSAGE_LENGTH_ANONYMOUS) {
        errors.rejectValue("msg", null, "Слишком большое сообщение");
      }
    } else {
      if (message.length() > MAX_MESSAGE_LENGTH) {
        errors.rejectValue("msg", null, "Слишком большое сообщение");
      }
    }

    Screenshot scrn = null;

    if (section!=null && groupPermissionService.isImagePostingAllowed(section, tmpl.getCurrentUser())) {
      scrn = processUpload(session, image, errors);

      if (section.isImagepost() && scrn == null && !errors.hasErrors()) {
        errors.reject(null, "Изображение отсутствует");
      }
    }

    Poll poll = null;
   
    if (section!=null && section.isPollPostAllowed()) {
      poll = preparePollPreview(form);
    }

    Topic previewMsg = null;

    if (group!=null) {
      previewMsg = new Topic(form, user, request.getRemoteAddr());

      Image imageObject = null;

      if (scrn!=null) {
        imageObject = new Image(
                0,
                0,
                "gallery/preview/" + scrn.getMainFile().getName(),
                "gallery/preview/" + scrn.getIconFile().getName()
        );
      }

      List<String> tagNames = TagName.parseAndSanitizeTags(form.getTags());

      if (!groupPermissionService.canCreateTag(section, tmpl.getCurrentUser())) {
        List<String> newTags = tagService.getNewTags(tagNames);

        if (!newTags.isEmpty()) {
          errors.rejectValue("tags", null, "Вы не можете создавать новые теги ("+ TagService.tagsToString(newTags)+")");
        }
      }

      PreparedTopic preparedTopic = prepareService.prepareTopicPreview(
              previewMsg,
              TagService.namesToRefs(tagNames),
              poll,
              request.isSecure(),
              message,
              imageObject
      );

      params.put("message", preparedTopic);

      TopicMenu topicMenu = prepareService.getTopicMenu(
              preparedTopic,
              tmpl.getCurrentUser(),
              request.isSecure(),
              tmpl.getProf(),
              true
      );

      params.put("topicMenu", topicMenu);
    }

    if (!form.isPreviewMode() && !errors.hasErrors()) {
      CSRFProtectionService.checkCSRF(request, errors);
    }

    if (!form.isPreviewMode() && !errors.hasErrors() && !tmpl.isSessionAuthorized()
      || ipBlockInfo.isCaptchaRequired()) {
      captcha.checkCaptcha(request, errors);
    }

    if (!form.isPreviewMode() && !errors.hasErrors()) {
View Full Code Here

          TopicListRequest topicListForm,
          @PathVariable String nick,
          HttpServletResponse response,
          @RequestParam(value = "offset", defaultValue = "0") int offset
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    TopicListController.setExpireHeaders(response, topicListForm.getYear(), topicListForm.getMonth());

    ModelAndView modelAndView = new ModelAndView();

    User user = getUserByNickname(modelAndView, nick);

    if (!tmpl.isModeratorSession() && !user.equals(tmpl.getCurrentUser())) {
      throw new AccessViolationException("Вы не можете смотреть черновики другого пользователя");
    }

    modelAndView.addObject("url",
            UriComponentsBuilder.fromUriString("/people/{nick}/drafts").buildAndExpand(nick).encode().toUriString());
View Full Code Here

        "messages",
        prepareService.prepareMessages(messages, request.isSecure())
      );
      modelAndView.setViewName("section-rss");
    } else {
      Template tmpl = Template.getTemplate(request);
      modelAndView.addObject(
        "messages",
        prepareService.prepareMessagesForUser(
                messages,
                request.isSecure(),
                tmpl.getCurrentUser(),
                tmpl.getProf(),
                false
        )
      );
    }
  }
View Full Code Here

    if (topicListForm.getSection() != null && topicListForm.getSection()!=0) {
      section = sectionService.getSection(topicListForm.getSection());
    }

    checkRequestConditions(section, group, topicListForm);
    Template tmpl = Template.getTemplate(request);

    ModelAndView modelAndView = new ModelAndView("view-news");

    modelAndView.addObject("group", group);

    modelAndView.addObject("url", "view-news.jsp");
    if (section != null) {
      modelAndView.addObject("section", section);

      modelAndView.addObject("archiveLink", section.getArchiveLink());
    }

    setExpireHeaders(response, topicListForm.getYear(), topicListForm.getMonth());

    modelAndView.addObject("navtitle", calculateNavTitle(section, group, topicListForm));

    topicListForm.setOffset(
      topicListService.fixOffset(topicListForm.getOffset())
    );

    List<Topic> messages = topicListService.getTopicsFeed(
      section,
      group,
      null,
      topicListForm.getOffset(),
      topicListForm.getYear(),
      topicListForm.getMonth(),
      20
    );

    modelAndView.addObject(
      "messages",
      prepareService.prepareMessagesForUser(
              messages,
              request.isSecure(),
              tmpl.getCurrentUser(),
              tmpl.getProf(),
              false
      )
    );

    modelAndView.addObject("offsetNavigation", topicListForm.getMonth() == null);
View Full Code Here

  @Autowired
  private DeleteInfoDao deleteInfoDao;

  @ModelAttribute("filters")
  public static List<TrackerFilterEnum> getFilter(HttpServletRequest request) {
    Template tmpl = Template.getTemplate(request);

    List<TrackerFilterEnum> filterValues = Arrays.asList(TrackerFilterEnum.values());

    if (tmpl.isSessionAuthorized()) {
      return filterValues;
    } else {
      return ImmutableList.copyOf(Iterables.filter(filterValues, not(equalTo(TrackerFilterEnum.MINE))));
    }
  }
View Full Code Here

  @RequestMapping("/tracker.jsp")
  public View trackerOldUrl(
          @RequestParam(value="filter", defaultValue = "all") String filterAction,
          HttpServletRequest request
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    TrackerFilterEnum defaultFilter = tmpl.getProf().getTrackerMode();

    RedirectView redirectView = new RedirectView("/tracker/");

    redirectView.setExposeModelAttributes(false);
View Full Code Here

      if (offset<0 || offset>300) {
        throw new UserErrorException("Некорректное значение offset");
      }
    }

    Template tmpl = Template.getTemplate(request);

    TrackerFilterEnum defaultFilter = tmpl.getProf().getTrackerMode();

    TrackerFilterEnum trackerFilter = TrackerFilterEnum.getByValue(filterAction).or(defaultFilter);

    Map<String, Object> params = new HashMap<>();
    params.put("offset", offset);
    params.put("filter", trackerFilter.getValue());

    if (trackerFilter != defaultFilter) {
      params.put("addition_query", "&amp;filter=" + trackerFilter.getValue());
    } else {
      params.put("addition_query", "");
    }

    params.put("defaultFilter", defaultFilter);

    Date startDate;

    if (trackerFilter == TrackerFilterEnum.MINE) {
      startDate = DateTime.now().minusMonths(6).toDate();
    } else {
      startDate = DateTime.now().minusDays(1).toDate();
    }

    int messages = tmpl.getProf().getMessages();
    int topics = tmpl.getProf().getTopics();

    params.put("topics", topics);

    User user = tmpl.getCurrentUser();

    params.put("title", makeTitle(trackerFilter, defaultFilter));

    if (trackerFilter == TrackerFilterEnum.MINE && !tmpl.isSessionAuthorized()) {
      throw new UserErrorException("Not authorized");
    }

    params.put("msgs", trackerDao.getTrackAll(trackerFilter, user, startDate, topics, offset, messages));

    if (tmpl.isModeratorSession() && trackerFilter != TrackerFilterEnum.MINE) {
      params.put("newUsers", userDao.getNewUsers());
      params.put("deleteStats", deleteInfoDao.getRecentStats());
    }

    return new ModelAndView("tracker", params);
View Full Code Here

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

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

    ModelAndView mv = new ModelAndView("setpostscore");
    Topic message = messageDao.getById(msgid);
View Full Code Here

    @RequestParam int msgid,
    @RequestParam int postscore,
    @RequestParam(defaultValue="false") boolean sticky,
    @RequestParam(defaultValue="false") boolean notop
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

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

    if (postscore < TopicPermissionService.POSTSCORE_UNRESTRICTED) {
      throw new UserErrorException("invalid postscore " + postscore);
    }

    if (postscore > TopicPermissionService.POSTSCORE_UNRESTRICTED && postscore < TopicPermissionService.POSTSCORE_REGISTERED_ONLY) {
      throw new UserErrorException("invalid postscore " + postscore);
    }

    if (postscore > TopicPermissionService.POSTSCORE_MODERATORS_ONLY) {
      throw new UserErrorException("invalid postscore " + postscore);
    }

    User user = tmpl.getCurrentUser();
    user.checkCommit();

    Topic msg = messageDao.getById(msgid);

    messageDao.setTopicOptions(msg, postscore, sticky, notop);
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.