Esempio n. 1
0
 @RequestMapping(value = "/register.jspx", method = RequestMethod.POST)
 public String submit(
     String username,
     String email,
     String password,
     CmsUserExt userExt,
     String captcha,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   WebErrors errors = validateSubmit(username, email, password, captcha, site, request, response);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   String ip = RequestUtils.getIpAddr(request);
   cmsUserMng.registerMember(username, email, password, ip, null, userExt);
   log.info("member register success. username={}", username);
   if (!StringUtils.isBlank(nextUrl)) {
     response.sendRedirect(nextUrl);
     return null;
   } else {
     return FrontUtils.showMessage(request, model, "global.success");
   }
 }
Esempio n. 2
0
 /**
  * 密码修改提交页
  *
  * @param origPwd 原始密码
  * @param newPwd 新密码
  * @param email 邮箱
  * @param nextUrl 下一个页面地址
  * @param request
  * @param response
  * @param model
  * @return
  * @throws IOException
  */
 @RequestMapping(value = "/member/pwd.jspx", method = RequestMethod.POST)
 public String passwordSubmit(
     String origPwd,
     String newPwd,
     String email,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   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 = validatePasswordSubmit(user.getId(), origPwd, newPwd, email, request);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   cmsUserMng.updatePwdEmail(user.getId(), newPwd, email);
   return FrontUtils.showSuccess(request, model, nextUrl);
 }
Esempio n. 3
0
 /**
  * 会员中心页
  *
  * <p>如果没有登录则跳转到登陆页
  *
  * @param request
  * @param response
  * @param model
  * @return
  */
 @RequestMapping(value = "/member/index.jspx", method = RequestMethod.GET)
 public String index(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);
   }
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, MEMBER_CENTER);
 }
Esempio n. 4
0
 @RequestMapping(value = "/register.jspx", method = RequestMethod.GET)
 public String input(HttpServletRequest request, HttpServletResponse response, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   // 没有开启会员注册
   if (!mcfg.isRegisterOn()) {
     return FrontUtils.showMessage(request, model, "member.registerClose");
   }
   FrontUtils.frontData(request, model, site);
   model.addAttribute("mcfg", mcfg);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER);
 }
Esempio n. 5
0
 @SuppressWarnings("unchecked")
 public void execute(
     Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
     throws TemplateException, IOException {
   CmsSite site = FrontUtils.getSite(env);
   String content = DirectiveUtils.getString(PARAM_CONTENT, params);
   if ("1".equals(content)) {
     String sysPage = DirectiveUtils.getString(PARAM_SYS_PAGE, params);
     String userPage = DirectiveUtils.getString(PARAM_USER_PAGE, params);
     if (!StringUtils.isBlank(sysPage)) {
       String tpl = TPL_STYLE_PAGE_CONTENT + sysPage + TPL_SUFFIX;
       env.include(tpl, UTF8, true);
     } else if (!StringUtils.isBlank(userPage)) {
       String tpl = getTplPath(site.getSolutionPath(), TPLDIR_STYLE_PAGE, userPage);
       env.include(tpl, UTF8, true);
     } else {
       // 没有包含分页
     }
   } else {
     FrontUtils.includePagination(site, params, env);
   }
 }
Esempio n. 6
0
 /**
  * 个人资料提交页
  *
  * @param request
  * @param response
  * @param model
  * @return
  * @throws IOException
  */
 @RequestMapping(value = "/member/profile.jspx", method = RequestMethod.POST)
 public String profileSubmit(
     CmsUserExt ext,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   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);
   }
   ext.setId(user.getId());
   cmsUserExtMng.update(ext, user);
   log.info("update CmsUserExt success. id={}", user.getId());
   return FrontUtils.showSuccess(request, model, nextUrl);
 }
  @SuppressWarnings("unchecked")
  public void execute(
      Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
      throws TemplateException, IOException {
    Integer siteId = getSiteId(params);
    if (siteId == null) {
      siteId = FrontUtils.getSite(env).getId();
    }
    Integer ctgId = getCtgId(params);
    Boolean enabled = getEnabled(params);
    if (enabled == null) {
      enabled = true;
    }
    List<CmsFriendlink> list = cmsFriendlinkMng.getList(siteId, ctgId, enabled);

    Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params);
    paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list));
    Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap);
    body.render(env.getOut());
    DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);
  }
  protected Object getData(Map<String, TemplateModel> params, Environment env)
      throws TemplateException {
    int orderBy = getOrderBy(params);
    Boolean titleImg = getHasTitleImg(params);
    Boolean recommend = getRecommend(params);
    Integer[] typeIds = getTypeIds(params);
    Integer[] siteIds = getSiteIds(params);
    String title = getTitle(params);
    int count = FrontUtils.getCount(params);

    Integer[] tagIds = getTagIds(params);
    if (tagIds != null) {
      Integer[] channelIds = getChannelIdsOrPaths(params, siteIds);
      Integer excludeId = DirectiveUtils.getInt(PARAM_EXCLUDE_ID, params);
      if (isPage()) {
        int pageNo = FrontUtils.getPageNo(env);
        return contentMng.getPageByTagIdsForTag(
            tagIds,
            siteIds,
            channelIds,
            typeIds,
            excludeId,
            titleImg,
            recommend,
            title,
            orderBy,
            pageNo,
            count);
      } else {
        int first = FrontUtils.getFirst(params);
        return contentMng.getListByTagIdsForTag(
            tagIds,
            siteIds,
            channelIds,
            typeIds,
            excludeId,
            titleImg,
            recommend,
            title,
            orderBy,
            first,
            count);
      }
    }
    Integer topicId = getTopicId(params);
    if (topicId != null) {
      Integer[] channelIds = getChannelIdsOrPaths(params, siteIds);
      if (isPage()) {
        int pageNo = FrontUtils.getPageNo(env);
        return contentMng.getPageByTopicIdForTag(
            topicId,
            siteIds,
            channelIds,
            typeIds,
            titleImg,
            recommend,
            title,
            orderBy,
            pageNo,
            count);
      } else {
        int first = FrontUtils.getFirst(params);
        return contentMng.getListByTopicIdForTag(
            topicId,
            siteIds,
            channelIds,
            typeIds,
            titleImg,
            recommend,
            title,
            orderBy,
            first,
            count);
      }
    }
    Integer[] channelIds = getChannelIds(params);
    if (channelIds != null) {
      int option = getChannelOption(params);
      if (isPage()) {
        int pageNo = FrontUtils.getPageNo(env);
        return contentMng.getPageByChannelIdsForTag(
            channelIds, typeIds, titleImg, recommend, title, orderBy, option, pageNo, count);
      } else {
        int first = FrontUtils.getFirst(params);
        return contentMng.getListByChannelIdsForTag(
            channelIds, typeIds, titleImg, recommend, title, orderBy, option, first, count);
      }
    }
    String[] channelPaths = getChannelPaths(params);
    if (channelPaths != null) {
      int option = getChannelOption(params);
      // 如果只有一个站点或只传入一个站点ID,则将栏目path转化为ID。
      boolean pathsToIds = false;
      Integer siteId = null;
      if (siteIds == null || siteIds.length == 0) {
        List<CmsSite> siteList = cmsSiteMng.getListFromCache();
        if (siteList.size() == 1) {
          pathsToIds = true;
          siteId = siteList.get(0).getId();
        }
      } else if (siteIds != null && siteIds.length == 1) {
        pathsToIds = true;
        siteId = siteIds[0];
      }
      if (pathsToIds) {
        channelIds = getChannelIdsByPaths(channelPaths, siteId);
        if (channelIds != null) {
          if (isPage()) {
            int pageNo = FrontUtils.getPageNo(env);
            return contentMng.getPageByChannelIdsForTag(
                channelIds, typeIds, titleImg, recommend, title, orderBy, option, pageNo, count);
          } else {
            int first = FrontUtils.getFirst(params);
            return contentMng.getListByChannelIdsForTag(
                channelIds, typeIds, titleImg, recommend, title, orderBy, option, first, count);
          }
        } else {
          // 如果将栏目path转换为ID后为空,则按path不存在处理,转到最后执行。
        }
      } else {
        if (isPage()) {
          int pageNo = FrontUtils.getPageNo(env);
          return contentMng.getPageByChannelPathsForTag(
              channelPaths, siteIds, typeIds, titleImg, recommend, title, orderBy, pageNo, count);
        } else {
          int first = FrontUtils.getFirst(params);
          return contentMng.getListByChannelPathsForTag(
              channelPaths, siteIds, typeIds, titleImg, recommend, title, orderBy, first, count);
        }
      }
    }
    // 主要条件为空,则执行此处代码。
    if (isPage()) {
      int pageNo = FrontUtils.getPageNo(env);
      return contentMng.getPageBySiteIdsForTag(
          siteIds, typeIds, titleImg, recommend, title, orderBy, pageNo, count);
    } else {
      int first = FrontUtils.getFirst(params);
      return contentMng.getListBySiteIdsForTag(
          siteIds, typeIds, titleImg, recommend, title, orderBy, first, count);
    }
  }