예제 #1
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);
 }
예제 #2
0
 public Content check(Integer id, CmsUser user) {
   Content content = findById(id);
   // 执行监听器
   List<Map<String, Object>> mapList = preChange(content);
   ContentCheck check = content.getContentCheck();
   byte userStep = user.getCheckStep(content.getSite().getId());
   byte contentStep = check.getCheckStep();
   byte finalStep = content.getChannel().getFinalStepExtends();
   // 用户审核级别小于当前审核级别,则不能审核
   if (userStep < contentStep) {
     return content;
   }
   check.setRejected(false);
   // 上级审核,清除退回意见。自我审核不清除退回意见。
   if (userStep > contentStep) {
     check.setCheckOpinion(null);
   }
   check.setCheckStep(userStep);
   // 终审
   if (userStep >= finalStep) {
     content.setStatus(ContentCheck.CHECKED);
     // 终审,清除退回意见
     check.setCheckOpinion(null);
     // 终审,设置审核者
     check.setReviewer(user);
     check.setCheckDate(Calendar.getInstance().getTime());
   }
   // 执行监听器
   afterChange(content, mapList);
   return content;
 }
예제 #3
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);
 }
예제 #4
0
  public Content reject(Integer id, CmsUser user, Byte step, String opinion) {
    Content content = findById(id);
    Integer siteId = content.getSite().getId();
    byte userStep = user.getCheckStep(siteId);
    byte contentStep = content.getCheckStep();
    // 用户审核级别小于当前审核级别,则不能退回
    if (userStep < contentStep) {
      return content;
    }
    // 执行监听器
    List<Map<String, Object>> mapList = preChange(content);
    ContentCheck check = content.getContentCheck();
    if (!StringUtils.isBlank(opinion)) {
      check.setCheckOpinion(opinion);
    }
    check.setRejected(true);
    // 退回稿件一律为未终审
    content.setStatus(ContentCheck.CHECKING);

    if (step != null) {
      // 指定退回级别,不能大于自身级别
      if (step < userStep) {
        check.setCheckStep(step);
      } else {
        check.setCheckStep(userStep);
      }
    } else {
      // 未指定退回级别
      if (contentStep < userStep) {
        // 文档级别小于用户级别,为审核时退回,文档审核级别不修改。
      } else if (contentStep == userStep) {
        // 文档级别等于用户级别,为退回时退回,文档审核级别减一级。
        check.setCheckStep((byte) (check.getCheckStep() - 1));
      }
    }
    // 执行监听器
    afterChange(content, mapList);
    return content;
  }
예제 #5
0
 @Transactional(readOnly = true)
 public Pagination getPageByRight(
     String title,
     Integer typeId,
     Integer inputUserId,
     boolean topLevel,
     boolean recommend,
     ContentStatus status,
     Byte checkStep,
     Integer siteId,
     Integer channelId,
     Integer userId,
     int orderBy,
     int pageNo,
     int pageSize) {
   CmsUser user = cmsUserMng.findById(userId);
   CmsUserSite us = user.getUserSite(siteId);
   Pagination p;
   boolean allChannel = us.getAllChannel();
   boolean selfData = user.getSelfAdmin();
   if (allChannel && selfData) {
     // 拥有所有栏目权限,只能管理自己的数据
     p =
         dao.getPageBySelf(
             title,
             typeId,
             inputUserId,
             topLevel,
             recommend,
             status,
             checkStep,
             siteId,
             channelId,
             userId,
             orderBy,
             pageNo,
             pageSize);
   } else if (allChannel && !selfData) {
     // 拥有所有栏目权限,能够管理不属于自己的数据
     p =
         dao.getPage(
             title,
             typeId,
             inputUserId,
             topLevel,
             recommend,
             status,
             checkStep,
             siteId,
             channelId,
             orderBy,
             pageNo,
             pageSize);
   } else {
     p =
         dao.getPageByRight(
             title,
             typeId,
             inputUserId,
             topLevel,
             recommend,
             status,
             checkStep,
             siteId,
             channelId,
             userId,
             selfData,
             orderBy,
             pageNo,
             pageSize);
   }
   return p;
 }
예제 #6
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;
 }
예제 #7
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;
 }
예제 #8
0
 /**
  * 验证密码是否正确
  *
  * @param origPwd 原密码
  * @param request
  * @param response
  */
 @RequestMapping("/member/checkPwd.jspx")
 public void checkPwd(String origPwd, HttpServletRequest request, HttpServletResponse response) {
   CmsUser user = CmsUtils.getUser(request);
   boolean pass = cmsUserMng.isPasswordValid(user.getId(), origPwd);
   ResponseUtils.renderJson(response, pass ? "true" : "false");
 }