Example #1
0
  public static String[] getThreadPriority(
      MBSettings mbSettings, String languageId, double value, ThemeDisplay themeDisplay)
      throws Exception {

    String[] priorities = mbSettings.getPriorities(languageId);

    String[] priorityPair = _findThreadPriority(value, themeDisplay, priorities);

    if (priorityPair == null) {
      String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getSiteDefault());

      priorities = mbSettings.getPriorities(defaultLanguageId);

      priorityPair = _findThreadPriority(value, themeDisplay, priorities);
    }

    return priorityPair;
  }
Example #2
0
  public static String[] getUserRank(
      MBSettings mbSettings, String languageId, MBStatsUser statsUser) throws Exception {

    String[] rank = {StringPool.BLANK, StringPool.BLANK};

    int maxPosts = 0;

    Group group = GroupLocalServiceUtil.getGroup(statsUser.getGroupId());

    long companyId = group.getCompanyId();

    String[] ranks = mbSettings.getRanks(languageId);

    for (int i = 0; i < ranks.length; i++) {
      String[] kvp = StringUtil.split(ranks[i], CharPool.EQUAL);

      String curRank = kvp[0];
      String curRankValue = kvp[1];

      String[] curRankValueKvp = StringUtil.split(curRankValue, CharPool.COLON);

      if (curRankValueKvp.length <= 1) {
        int posts = GetterUtil.getInteger(curRankValue);

        if ((posts <= statsUser.getMessageCount()) && (posts >= maxPosts)) {

          rank[0] = curRank;
          maxPosts = posts;
        }
      } else {
        String entityType = curRankValueKvp[0];
        String entityValue = curRankValueKvp[1];

        try {
          if (_isEntityRank(companyId, statsUser, entityType, entityValue)) {

            rank[1] = curRank;

            break;
          }
        } catch (Exception e) {
          if (_log.isWarnEnabled()) {
            _log.warn(e);
          }
        }
      }
    }

    return rank;
  }
Example #3
0
  public static String getUserRank(MBSettings mbSettings, String languageId, int posts)
      throws Exception {

    String rank = StringPool.BLANK;

    String[] ranks = mbSettings.getRanks(languageId);

    for (int i = 0; i < ranks.length; i++) {
      String[] kvp = StringUtil.split(ranks[i], CharPool.EQUAL);

      String kvpName = kvp[0];
      int kvpPosts = GetterUtil.getInteger(kvp[1]);

      if (posts >= kvpPosts) {
        rank = kvpName;
      } else {
        break;
      }
    }

    return rank;
  }