/**
  * 获取ID数组,如果ID不存在则获取PATH数组。
  *
  * @param params 标签参数
  * @param siteIds 如果为null,则自动获取所有站点path
  * @return 如果不存在,则返回null。
  * @throws TemplateException
  */
 protected Integer[] getChannelIdsOrPaths(Map<String, TemplateModel> params, Integer[] siteIds)
     throws TemplateException {
   Integer[] ids = getChannelIds(params);
   if (ids != null) {
     return ids;
   }
   String[] paths = getChannelPaths(params);
   if (paths == null) {
     return null;
   }
   Set<Integer> set = new HashSet<Integer>();
   Channel channel;
   if (siteIds == null) {
     List<CmsSite> list = cmsSiteMng.getListFromCache();
     siteIds = new Integer[list.size()];
     int i = 0;
     for (CmsSite site : list) {
       siteIds[i++] = site.getId();
     }
   }
   for (Integer siteId : siteIds) {
     for (String path : paths) {
       channel = channelMng.findByPathForTag(path, siteId);
       if (channel != null) {
         set.add(channel.getId());
       }
     }
   }
   if (set.size() > 0) {
     return set.toArray(new Integer[set.size()]);
   } else {
     return null;
   }
 }
Beispiel #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);
 }
Beispiel #3
0
 private WebErrors validateUpdate(Integer id, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (vldExist(id, site.getId(), errors)) {
     return errors;
   }
   return errors;
 }
Beispiel #4
0
 @RequestMapping("/vote_topic/v_list.do")
 public String list(Integer pageNo, HttpServletRequest request, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   Pagination pagination =
       manager.getPage(site.getId(), cpn(pageNo), CookieUtils.getPageSize(request));
   model.addAttribute("pagination", pagination);
   model.addAttribute("pageNo", pagination.getPageNo());
   return "vote_topic/list";
 }
Beispiel #5
0
 private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (errors.ifEmpty(ids, "ids")) {
     return errors;
   }
   for (Integer id : ids) {
     vldExist(id, site.getId(), errors);
   }
   return errors;
 }
Beispiel #6
0
 public CmsSite update(CmsSite bean, Integer uploadFtpId) {
   CmsSite entity = findById(bean.getId());
   if (uploadFtpId != null) {
     entity.setUploadFtp(ftpMng.findById(uploadFtpId));
   } else {
     entity.setUploadFtp(null);
   }
   Updater<CmsSite> updater = new Updater<CmsSite>(bean);
   entity = dao.updateByUpdater(updater);
   return entity;
 }
Beispiel #7
0
 public CmsSite save(CmsSite currSite, CmsUser currUser, CmsSite bean, Integer uploadFtpId)
     throws IOException {
   if (uploadFtpId != null) {
     bean.setUploadFtp(ftpMng.findById(uploadFtpId));
   }
   bean.init();
   dao.save(bean);
   // 复制本站模板
   cmsResourceMng.copyTplAndRes(currSite, bean);
   // 处理管理员
   cmsUserMng.addSiteToUser(currUser, bean, bean.getFinalStep());
   return bean;
 }
Beispiel #8
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);
 }
Beispiel #9
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);
 }
Beispiel #10
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);
   }
 }
Beispiel #11
0
 @RequestMapping(value = "/username_unique.jspx")
 public void usernameUnique(HttpServletRequest request, HttpServletResponse response) {
   String username = RequestUtils.getQueryParam(request, "username");
   // 用户名为空,返回false。
   if (StringUtils.isBlank(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   CmsSite site = CmsUtils.getSite(request);
   CmsConfig config = site.getConfig();
   // 保留字检查不通过,返回false。
   if (!config.getMemberConfig().checkUsernameReserved(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   // 用户名存在,返回false。
   if (unifiedUserMng.usernameExist(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   ResponseUtils.renderJson(response, "true");
 }
Beispiel #12
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);
 }
Beispiel #13
0
 private WebErrors validateSubmit(
     String username,
     String email,
     String password,
     String captcha,
     CmsSite site,
     HttpServletRequest request,
     HttpServletResponse response) {
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   WebErrors errors = WebErrors.create(request);
   try {
     if (!imageCaptchaService.validateResponseForID(
         session.getSessionId(request, response), captcha)) {
       errors.addErrorCode("error.invalidCaptcha");
       return errors;
     }
   } catch (CaptchaServiceException e) {
     errors.addErrorCode("error.exceptionCaptcha");
     log.warn("", e);
     return errors;
   }
   if (errors.ifOutOfLength(username, "username", mcfg.getUsernameMinLen(), 100)) {
     return errors;
   }
   if (errors.ifOutOfLength(password, "password", mcfg.getPasswordMinLen(), 100)) {
     return errors;
   }
   if (errors.ifMaxLength(email, "email", 100)) {
     return errors;
   }
   // 保留字检查不通过,返回false。
   if (!mcfg.checkUsernameReserved(username)) {
     errors.addErrorCode("error.usernameReserved");
     return errors;
   }
   // 用户名存在,返回false。
   if (unifiedUserMng.usernameExist(username)) {
     errors.addErrorCode("error.usernameExist");
     return errors;
   }
   return errors;
 }
Beispiel #14
0
 public Content update(
     Content bean,
     ContentExt ext,
     ContentTxt txt,
     String[] tagArr,
     Integer[] channelIds,
     Integer[] topicIds,
     Integer[] viewGroupIds,
     String[] attachmentPaths,
     String[] attachmentNames,
     String[] attachmentFilenames,
     String[] picPaths,
     String[] picDescs,
     Map<String, String> attr,
     Integer channelId,
     Integer typeId,
     Boolean draft,
     CmsUser user,
     boolean forMember) {
   Content entity = findById(bean.getId());
   // 执行监听器
   List<Map<String, Object>> mapList = preChange(entity);
   // 更新主表
   Updater<Content> updater = new Updater<Content>(bean);
   bean = dao.updateByUpdater(updater);
   // 审核更新处理,如果站点设置为审核退回,且当前文章审核级别大于管理员审核级别,则将文章审核级别修改成管理员的审核级别。
   Byte userStep;
   if (forMember) {
     // 会员的审核级别按0处理
     userStep = 0;
   } else {
     CmsSite site = bean.getSite();
     userStep = user.getCheckStep(site.getId());
   }
   AfterCheckEnum after = bean.getChannel().getAfterCheckEnum();
   if (after == AfterCheckEnum.BACK_UPDATE && bean.getCheckStep() > userStep) {
     bean.getContentCheck().setCheckStep(userStep);
     if (bean.getCheckStep() >= bean.getChannel().getFinalStepExtends()) {
       bean.setStatus(ContentCheck.CHECKED);
     } else {
       bean.setStatus(ContentCheck.CHECKING);
     }
   }
   // 草稿
   if (draft != null) {
     if (draft) {
       bean.setStatus(DRAFT);
     } else {
       if (bean.getStatus() == DRAFT) {
         if (bean.getCheckStep() >= bean.getChannel().getFinalStepExtends()) {
           bean.setStatus(ContentCheck.CHECKED);
         } else {
           bean.setStatus(ContentCheck.CHECKING);
         }
       }
     }
   }
   // 是否有标题图
   bean.setHasTitleImg(!StringUtils.isBlank(ext.getTitleImg()));
   // 更新栏目
   if (channelId != null) {
     bean.setChannel(channelMng.findById(channelId));
   }
   // 更新类型
   if (typeId != null) {
     bean.setType(contentTypeMng.findById(typeId));
   }
   // 更新扩展表
   contentExtMng.update(ext);
   // 更新文本表
   contentTxtMng.update(txt, bean);
   // 更新属性表
   if (attr != null) {
     Map<String, String> attrOrig = bean.getAttr();
     attrOrig.clear();
     attrOrig.putAll(attr);
   }
   // 更新副栏目表
   Set<Channel> channels = bean.getChannels();
   channels.clear();
   if (channelIds != null && channelIds.length > 0) {
     for (Integer cid : channelIds) {
       channels.add(channelMng.findById(cid));
     }
   }
   channels.add(bean.getChannel());
   // 更新专题表
   Set<CmsTopic> topics = bean.getTopics();
   topics.clear();
   if (topicIds != null && topicIds.length > 0) {
     for (Integer tid : topicIds) {
       topics.add(cmsTopicMng.findById(tid));
     }
   }
   // 更新浏览会员组
   Set<CmsGroup> groups = bean.getViewGroups();
   groups.clear();
   if (viewGroupIds != null && viewGroupIds.length > 0) {
     for (Integer gid : viewGroupIds) {
       groups.add(cmsGroupMng.findById(gid));
     }
   }
   // 更新标签
   contentTagMng.updateTags(bean.getTags(), tagArr);
   // 更新附件
   bean.getAttachments().clear();
   if (attachmentPaths != null && attachmentPaths.length > 0) {
     for (int i = 0, len = attachmentPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(attachmentPaths[i])) {
         bean.addToAttachmemts(attachmentPaths[i], attachmentNames[i], attachmentFilenames[i]);
       }
     }
   }
   // 更新图片集
   bean.getPictures().clear();
   if (picPaths != null && picPaths.length > 0) {
     for (int i = 0, len = picPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(picPaths[i])) {
         bean.addToPictures(picPaths[i], picDescs[i]);
       }
     }
   }
   // 执行监听器
   afterChange(bean, mapList);
   return bean;
 }
Beispiel #15
0
 public Content save(
     Content bean,
     ContentExt ext,
     ContentTxt txt,
     Integer[] channelIds,
     Integer[] topicIds,
     Integer[] viewGroupIds,
     String[] tagArr,
     String[] attachmentPaths,
     String[] attachmentNames,
     String[] attachmentFilenames,
     String[] picPaths,
     String[] picDescs,
     Integer channelId,
     Integer typeId,
     Boolean draft,
     CmsUser user,
     boolean forMember) {
   bean.setChannel(channelMng.findById(channelId));
   bean.setType(contentTypeMng.findById(typeId));
   bean.setUser(user);
   Byte userStep;
   if (forMember) {
     // 会员的审核级别按0处理
     userStep = 0;
   } else {
     CmsSite site = bean.getSite();
     userStep = user.getCheckStep(site.getId());
   }
   if (draft != null && draft) {
     bean.setStatus(ContentCheck.DRAFT);
   } else {
     if (userStep >= bean.getChannel().getFinalStepExtends()) {
       bean.setStatus(ContentCheck.CHECKED);
     } else {
       bean.setStatus(ContentCheck.CHECKING);
     }
   }
   // 是否有标题图
   bean.setHasTitleImg(!StringUtils.isBlank(ext.getTitleImg()));
   bean.init();
   // 执行监听器
   preSave(bean);
   dao.save(bean);
   contentExtMng.save(ext, bean);
   contentTxtMng.save(txt, bean);
   ContentCheck check = new ContentCheck();
   check.setCheckStep(userStep);
   contentCheckMng.save(check, bean);
   contentCountMng.save(new ContentCount(), bean);
   // 保存副栏目
   if (channelIds != null && channelIds.length > 0) {
     for (Integer cid : channelIds) {
       bean.addToChannels(channelMng.findById(cid));
     }
   }
   // 主栏目也作为副栏目一并保存,方便查询,提高效率。
   bean.addToChannels(channelMng.findById(channelId));
   // 保存专题
   if (topicIds != null && topicIds.length > 0) {
     for (Integer tid : topicIds) {
       bean.addToTopics(cmsTopicMng.findById(tid));
     }
   }
   // 保存浏览会员组
   if (viewGroupIds != null && viewGroupIds.length > 0) {
     for (Integer gid : viewGroupIds) {
       bean.addToGroups(cmsGroupMng.findById(gid));
     }
   }
   // 保存标签
   List<ContentTag> tags = contentTagMng.saveTags(tagArr);
   bean.setTags(tags);
   // 保存附件
   if (attachmentPaths != null && attachmentPaths.length > 0) {
     for (int i = 0, len = attachmentPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(attachmentPaths[i])) {
         bean.addToAttachmemts(attachmentPaths[i], attachmentNames[i], attachmentFilenames[i]);
       }
     }
   }
   // 保存图片集
   if (picPaths != null && picPaths.length > 0) {
     for (int i = 0, len = picPaths.length; i < len; i++) {
       if (!StringUtils.isBlank(picPaths[i])) {
         bean.addToPictures(picPaths[i], picDescs[i]);
       }
     }
   }
   // 执行监听器
   afterSave(bean);
   return bean;
 }
Beispiel #16
0
 public void updateTplSolution(Integer siteId, String solution) {
   CmsSite site = findById(siteId);
   site.setTplSolution(solution);
 }