Package com.jeecms.cms.entity.main

Examples of com.jeecms.cms.entity.main.CmsUser


  @Override
  public void postHandle(HttpServletRequest request,
      HttpServletResponse response, Object handler, ModelAndView mav)
      throws Exception {
    CmsUser user = CmsUtils.getUser(request);
    // 不控制权限时perm为null,PermistionDirective标签将以此作为依据不处理权限问题。
    if (auth && user != null && !user.isSuper() && mav != null
        && mav.getModelMap() != null && mav.getViewName() != null
        && !mav.getViewName().startsWith("redirect:")) {
      mav.getModelMap().addAttribute(PERMISSION_MODEL, user.getPerms());
    }
  }
View Full Code Here


   * 获得用户ID   *
   * @param request
   * @return
   */
  public static Integer getUserId(HttpServletRequest request) {
    CmsUser user = getUser(request);
    if (user != null) {
      return user.getId();
    } else {
      return null;
    }
  }
View Full Code Here

   * @return
   */
  @RequestMapping(value = "/member/contribute_add.jspx")
  public String add(HttpServletRequest request, ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    FrontUtils.frontData(request, model, site);
    MemberConfig mcfg = site.getConfig().getMemberConfig();
    // 没有开启会员功能
    if (!mcfg.isMemberOn()) {
      return FrontUtils.showMessage(request, model, "member.memberClose");
    }
    if (user == null) {
      return FrontUtils.showLogin(request, model, site);
    }
    // 获得本站栏目列表
    Set<Channel> rights = user.getGroup().getContriChannels();
    List<Channel> topList = channelMng.getTopList(site.getId(), true);
    List<Channel> channelList = Channel.getListForSelect(topList, rights,
        true);
    model.addAttribute("channelList", channelList);
    return FrontUtils.getTplPath(request, site.getSolutionPath(),
View Full Code Here

  public String save(String title, String author, String description,
      String txt, String tagStr, Integer channelId, String captcha,
      String nextUrl, HttpServletRequest request,
      HttpServletResponse response, ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    FrontUtils.frontData(request, model, site);
    MemberConfig mcfg = site.getConfig().getMemberConfig();
    // 没有开启会员功能
    if (!mcfg.isMemberOn()) {
      return FrontUtils.showMessage(request, model, "member.memberClose");
View Full Code Here

   */
  @RequestMapping(value = "/member/contribute_edit.jspx")
  public String edit(Integer id, HttpServletRequest request,
      HttpServletResponse response, ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    FrontUtils.frontData(request, model, site);
    MemberConfig mcfg = site.getConfig().getMemberConfig();
    // 没有开启会员功能
    if (!mcfg.isMemberOn()) {
      return FrontUtils.showMessage(request, model, "member.memberClose");
    }
    if (user == null) {
      return FrontUtils.showLogin(request, model, site);
    }
    WebErrors errors = validateEdit(id, site, user, request);
    if (errors.hasErrors()) {
      return FrontUtils.showError(request, response, model, errors);
    }
    Content content = contentMng.findById(id);
    // 获得本站栏目列表
    Set<Channel> rights = user.getGroup().getContriChannels();
    List<Channel> topList = channelMng.getTopList(site.getId(), true);
    List<Channel> channelList = Channel.getListForSelect(topList, rights,
        true);
    model.addAttribute("content", content);
    model.addAttribute("channelList", channelList);
View Full Code Here

  public String update(Integer id, String title, String author,
      String description, String txt, String tagStr, Integer channelId,
      String nextUrl, HttpServletRequest request,
      HttpServletResponse response, ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    FrontUtils.frontData(request, model, site);
    MemberConfig mcfg = site.getConfig().getMemberConfig();
    // 没有开启会员功能
    if (!mcfg.isMemberOn()) {
      return FrontUtils.showMessage(request, model, "member.memberClose");
View Full Code Here

   */
  @RequestMapping(value = "/member/contribute_delete.jspx")
  public String delete(Integer[] ids, HttpServletRequest request,
      String nextUrl, HttpServletResponse response, ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    FrontUtils.frontData(request, model, site);
    MemberConfig mcfg = site.getConfig().getMemberConfig();
    // 没有开启会员功能
    if (!mcfg.isMemberOn()) {
      return FrontUtils.showMessage(request, model, "member.memberClose");
View Full Code Here

        String ip = RequestUtils.getIpAddr(request);
        Authentication auth = authMng.login(username, password, ip,
            request, response, session);
        // 是否需要在这里加上登录次数的更新?按正常的方式,应该在process里面处理的,不过这里处理也没大问题。
        cmsUserMng.updateLoginInfo(auth.getUid(), ip);
        CmsUser user = cmsUserMng.findById(auth.getUid());
        if (user.getDisabled()) {
          // 如果已经禁用,则推出登录。
          authMng.deleteById(auth.getId());
          session.logout(request, response);
          throw new DisabledException("user disabled");
        }
View Full Code Here

   */
  @RequestMapping(value = "/member/contribute_list.jspx")
  public String list(String queryTitle, Integer queryChannelId,
      Integer pageNo, HttpServletRequest request, ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    FrontUtils.frontData(request, model, site);
    MemberConfig mcfg = site.getConfig().getMemberConfig();
    // 没有开启会员功能
    if (!mcfg.isMemberOn()) {
      return FrontUtils.showMessage(request, model, "member.memberClose");
    }
    if (user == null) {
      return FrontUtils.showLogin(request, model, site);
    }
    Pagination p = contentMng.getPageForMember(queryTitle, queryChannelId,
        site.getId(), user.getId(), cpn(pageNo), 20);
    model.addAttribute("pagination", p);
    if (!StringUtils.isBlank(queryTitle)) {
      model.addAttribute("queryTitle", queryTitle);
    }
    if (queryChannelId != null) {
View Full Code Here

    try {
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
      // We upload just one file at the same time
      MultipartFile uplFile = multipartRequest.getFileMap().entrySet()
          .iterator().next().getValue();
      CmsUser user = CmsUtils.getUser(request);
      int fileSize = (int) (uplFile.getSize() / 1024);
      // 文件太大,不允许上传
      if (!user.isAllowMaxFile(fileSize)) {
        log.warn("member fck upload warn: not allow max file: {}",
            fileSize);
        return UploadResponse.getFileUploadDisabledError(request);
      }
      // 文件上传今日额度已经用完
      if (!user.isAllowPerDay(fileSize)) {
        log.warn("member fck upload warn: not allow per day: {}",
            fileSize);
        return UploadResponse.getFileUploadDisabledError(request);
      }
      // Some browsers transfer the entire source path not just the
      // filename
      String filename = FilenameUtils.getName(uplFile
          .getOriginalFilename());
      log.debug("Parameter NewFile: {}", filename);
      String ext = FilenameUtils.getExtension(filename);
      // 不允许上传的文件后缀
      if (!user.isAllowSuffix(ext)) {
        log.warn("member fck upload warn:"
            + " not allow file extension: {}", ext);
        return UploadResponse.getFileUploadDisabledError(request);
      }
      if (type.isDeniedExtension(ext)) {
        return UploadResponse.getInvalidFileTypeError(request);
      }
      if (type.equals(ResourceType.IMAGE)
          && !ImageUtils.isImage(uplFile.getInputStream())) {
        return UploadResponse.getInvalidFileTypeError(request);
      }
      String fileUrl;
      CmsSite site = CmsUtils.getSite(request);
      MarkConfig conf = site.getConfig().getMarkConfig();
      if (mark == null) {
        mark = conf.getOn();
      }
      boolean isImg = type.equals(ResourceType.IMAGE);
      if (site.getConfig().getUploadToDb()) {
        if (mark && isImg) {
          File tempFile = mark(uplFile, conf);
          fileUrl = dbFileMng.storeByExt(site.getUploadPath(), ext,
              new FileInputStream(tempFile));
          tempFile.delete();
        } else {
          fileUrl = dbFileMng.storeByExt(site.getUploadPath(), ext,
              uplFile.getInputStream());
        }
        // 加上访问地址
        String dbFilePath = site.getConfig().getDbFileUri();
        fileUrl = request.getContextPath() + dbFilePath + fileUrl;
      } else if (site.getUploadFtp() != null) {
        Ftp ftp = site.getUploadFtp();
        if (mark && isImg) {
          File tempFile = mark(uplFile, conf);
          fileUrl = ftp.storeByExt(site.getUploadPath(), ext,
              new FileInputStream(tempFile));
          tempFile.delete();
        } else {
          fileUrl = ftp.storeByExt(site.getUploadPath(), ext, uplFile
              .getInputStream());
        }
        // 加上url前缀
        fileUrl = ftp.getUrl() + fileUrl;
      } else {
        if (mark && isImg) {
          File tempFile = mark(uplFile, conf);
          fileUrl = fileRepository.storeByExt(site.getUploadPath(),
              ext, tempFile);
          tempFile.delete();
        } else {
          fileUrl = fileRepository.storeByExt(site.getUploadPath(),
              ext, uplFile);
        }
        // 加上部署路径
        fileUrl = request.getContextPath() + fileUrl;
      }
      cmsUserMng.updateUploadSize(user.getId(), fileSize);
      return UploadResponse.getOK(request, fileUrl);
    } catch (IOException e) {
      return UploadResponse.getFileUploadWriteError(request);
    }
  }
View Full Code Here

TOP

Related Classes of com.jeecms.cms.entity.main.CmsUser

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.