Package com.jeecms.cms.entity.main

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


  public void submit(Integer siteId, Integer ctgId, String title,
      String content, String email, String phone, String qq,
      String captcha, HttpServletRequest request,
      HttpServletResponse response, ModelMap model) throws JSONException {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser member = CmsUtils.getUser(request);
    if (siteId == null) {
      siteId = site.getId();
    }
    JSONObject json = new JSONObject();
    try {
View Full Code Here


    f.append(" order by bean.id asc");
    return find(f);
  }

  public CmsUser findById(Integer id) {
    CmsUser entity = get(id);
    return entity;
  }
View Full Code Here

    getSession().save(bean);
    return bean;
  }

  public CmsUser deleteById(Integer id) {
    CmsUser entity = super.get(id);
    if (entity != null) {
      getSession().delete(entity);
    }
    return entity;
  }
View Full Code Here

      }
    }
   
    CmsUtils.setSite(request, site);

    CmsUser user = null;
    Integer userId = authMng.retrieveUserIdFromSession(session, request);
    if (userId != null) {
      user = cmsUserMng.findById(userId);
    }
   
View Full Code Here

    Content content = contentMng.findById(id);
    if (content == null) {
      log.debug("Content id not found: {}", id);
      return FrontUtils.pageNotFound(request, response, model);
    }
    CmsUser user = CmsUtils.getUser(request);
    CmsSite site = content.getSite();
    Set<CmsGroup> groups = content.getViewGroupsExt();
    int len = groups.size();
    // 需要浏览权限
    if (len != 0) {
      // 没有登录
      if (user == null) {
        return FrontUtils.showLogin(request, model, site);
      }
      // 已经登录但没有权限
      Integer gid = user.getGroup().getId();
      boolean right = false;
      for (CmsGroup group : groups) {
        if (group.getId().equals(gid)) {
          right = true;
          break;
        }
      }
      if (!right) {
        String gname = user.getGroup().getName();
        return FrontUtils.showMessage(request, model, GROUP_FORBIDDEN,
            gname);
      }
    }
    String txt = content.getTxtByNo(pageNo);
View Full Code Here

   * @param request
   * @param model
   */
  public static void frontData(HttpServletRequest request,
      Map<String, Object> map, CmsSite site) {
    CmsUser user = CmsUtils.getUser(request);
    String location = RequestUtils.getLocation(request);
    Long startTime = (Long) request.getAttribute(START_TIME);
    frontData(map, site, user, location, startTime);
  }
View Full Code Here

  @RequestMapping(value = "/vote.jspx", method = RequestMethod.POST)
  public String submit(Integer voteId, Integer[] itemIds,
      HttpServletRequest request, HttpServletResponse response,
      ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    String ip = RequestUtils.getIpAddr(request);
    String cookieName = VOTE_COOKIE_PREFIX + voteId;
    Cookie cookie = CookieUtils.getCookie(request, cookieName);
    String cookieValue;
    if (cookie != null && !StringUtils.isBlank(cookie.getValue())) {
View Full Code Here

  @RequestMapping(value = "/comment.jspx", method = RequestMethod.POST)
  public void submit(Integer contentId, String text, String captcha,
      HttpServletRequest request, HttpServletResponse response,
      ModelMap model) throws JSONException {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    JSONObject json = new JSONObject();
    if (contentId == null) {
      json.put("success", false);
      json.put("status", 100);
      ResponseUtils.renderJson(response, json.toString());
      return;
    }
    if (StringUtils.isBlank(text)) {
      json.put("success", false);
      json.put("status", 101);
      ResponseUtils.renderJson(response, json.toString());
      return;
    }
    if (user == null || user.getGroup().getNeedCaptcha()) {
      // 验证码错误
      try {
        if (!imageCaptchaService.validateResponseForID(session
            .getSessionId(request, response), captcha)) {
          json.put("success", false);
          json.put("status", 1);
          ResponseUtils.renderJson(response, json.toString());
          return;
        }
      } catch (CaptchaServiceException e) {
        json.put("success", false);
        json.put("status", 1);
        log.warn("", e);
        ResponseUtils.renderJson(response, json.toString());
        return;
      }
    }
    Content content = contentMng.findById(contentId);
    if (content == null) {
      // 内容不存在
      json.put("success", false);
      json.put("status", 2);
    } else if (content.getChannel().getCommentControl() == ChannelExt.COMMENT_OFF) {
      // 评论关闭
      json.put("success", false);
      json.put("status", 3);
    } else if (content.getChannel().getCommentControl() == ChannelExt.COMMENT_LOGIN
        && user == null) {
      // 需要登录才能评论
      json.put("success", false);
      json.put("status", 4);
    } else {
      boolean checked = false;
      Integer userId = null;
      if (user != null) {
        checked = !user.getGroup().getNeedCheck();
        userId = user.getId();
      }
      cmsCommentMng.comment(text, RequestUtils.getIpAddr(request),
          contentId, site.getId(), userId, checked, false);
      json.put("success", true);
      json.put("status", 0);
View Full Code Here

      ModelMap model) {
    String queryInputUsername = RequestUtils.getQueryParam(request,
        "queryInputUsername");
    Integer queryInputUserId = null;
    if (!StringUtils.isBlank(queryInputUsername)) {
      CmsUser u = cmsUserMng.findByUsername(queryInputUsername);
      if (u != null) {
        queryInputUserId = u.getId();
      } else {
        // 用户名不存在,清空。
        queryInputUsername = null;
      }
    }
View Full Code Here

    CmsUtils.setSite(request, site);
    // Site加入线程变量
    CmsThreadVariable.setSite(site);

    // 获得用户
    CmsUser user = null;
    if (adminId != null) {
      // 指定管理员(开发状态)
      user = cmsUserMng.findById(adminId);
      if (user == null) {
        throw new IllegalStateException("User ID=" + adminId
            + " not found!");
      }
    } else {
      // 正常状态
      Integer userId = authMng
          .retrieveUserIdFromSession(session, request);
      if (userId != null) {
        user = cmsUserMng.findById(userId);
      }
    }
   
    // 此时用户可以为null
    CmsUtils.setUser(request, user);
   
    // User加入线程变量
    CmsThreadVariable.setUser(user);

    String uri = getURI(request);
    // 不在验证的范围内
    if (exclude(uri)) {
      return true;
    }
    // 用户为null跳转到登陆页面
    if (user == null) {
      response.sendRedirect(getLoginUrl(request));
      return false;
    }
    // 用户不是管理员,提示无权限。
    if (!user.getAdmin()) {
      request.setAttribute(MESSAGE, MessageResolver.getMessage(request,
          "login.notAdmin"));
      response.sendError(HttpServletResponse.SC_FORBIDDEN);
      return false;
    }
   
    // 不属于该站点的管理员,提示无权限。
    if (!user.getSites().contains(site)) {
      request.setAttribute(MESSAGE, MessageResolver.getMessage(request,
          "login.notInSite"));
      response.sendError(HttpServletResponse.SC_FORBIDDEN);
      return false;
    }
   
    boolean viewonly = user.getViewonlyAdmin();
    // 没有访问权限,提示无权限。
    if (auth && !user.isSuper()
        && !permistionPass(uri, user.getPerms(), viewonly)) {
      request.setAttribute(MESSAGE, MessageResolver.getMessage(request,
          "login.notPermission"));
      response.sendError(HttpServletResponse.SC_FORBIDDEN);
      return false;
    }
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.