Пример #1
0
 public static int getTotalPrivateSearchPageCount(String searchTerm, String user, int pageSize) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("members.email", user)
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Пример #2
0
 public static List<Scenario> findInvolvingUserSearch(
     String searchTerm, String user, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("members.email", user)
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Пример #3
0
 public static int getTotalPublicAcceptedNotExpiredPageCount(int pageSize, Date currentDate) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isPublic", true)
           .eq("isAccepted", true)
           .or(
               com.avaje.ebean.Expr.lt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Пример #4
0
 public static List<Scenario> findToAccept(Date currentDate, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isAccepted", false)
           .eq("isPublic", true)
           .or(
               com.avaje.ebean.Expr.lt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Пример #5
0
 public static List<Scenario> findPublicAcceptedNotExpiredSearch(
     String searchTerm, Date currentDate, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isPublic", true)
           .eq("isAccepted", true)
           .or(
               com.avaje.ebean.Expr.gt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Пример #6
0
  @Override
  public boolean onCommand(
      CommandSender sender, Command command, String commandLabel, String[] args) {

    // Default parameter values
    String[] parameters = this.getParameters(args);
    int page = Integer.parseInt(parameters[0]);
    String type = parameters[1];

    ModTRSCommandSender player = new ModTRSCommandSender(sender);

    if (!parameters[2].isEmpty()) {
      CheckIdCommand checkid = new CheckIdCommand(parent);

      if (ValidatorHandler.getInstance().hasValidator("check-id")) {
        if (!ValidatorHandler.getInstance()
            .getValidator("check-id")
            .isValid(new String[] {parameters[2].trim()})) {
          return false;
        }
      }
      return checkid.onCommand(sender, command, commandLabel, new String[] {parameters[2].trim()});
    }

    CommandCheckEvent event = new CommandCheckEvent(page, type, player);
    EventHandler.getInstance().dispatch(event);
    if (event.isCancelled()) {
      return true;
    }

    page = event.getPage();
    type = event.getRequestType();
    player = event.getSender();

    PagingList<ModTRSRequest> pager;
    boolean isModerator = true;

    try {

      if (!player.hasPerm("modtrs.command.check")) {
        if (!player.hasPerm("modtrs.command.check.self", false)) {
          player.sendMessage(Message.parse("general.error.permission"));
          return true;
        } else {
          isModerator = false;
          pager =
              parent
                  .getTableHandler()
                  .getRequest()
                  .getOpenRequestsFromUserPager(player.getName(), ModTRSSettings.reqsPerPage);
        }
      } else {
        pager =
            parent
                .getTableHandler()
                .getRequest()
                .getRequestsPager(type, ModTRSSettings.reqsPerPage);
      }

      String ucfirst = type.toUpperCase().substring(0, 1) + type.substring(1);
      player.sendMessage(Message.parse("check.intro", pager.getTotalRowCount(), ucfirst));

      if (pager.getTotalRowCount() == 0) {
        player.sendMessage(Message.parse("check.no_reqs"));
      }

      int count = 0;
      for (ModTRSRequest request : pager.getPage(page - 1).getList()) {
        count++;

        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(CommandHandler.TIMEDATE_FORMAT);
        calendar.setTimeInMillis(request.getTstamp());

        String substring = request.getText();

        if (substring.length() >= 20) {
          substring = substring.substring(0, 20) + "...";
        }

        boolean online =
            ModTRSFunctions.isUserOnline(
                parent.getTableHandler().getUser().getUserFromId(request.getUserId()).getName(),
                player.getServer());
        if (request.getStatus() == 1) {
          player.sendMessage(
              Message.parse(
                  "check.item.claimed",
                  request.getId(),
                  sdf.format(calendar.getTime()),
                  (online) ? ChatColor.GREEN : ChatColor.RED,
                  parent.getTableHandler().getUser().getUserFromId(request.getUserId()).getName(),
                  parent.getTableHandler().getUser().getUserFromId(request.getModId()).getName()));
        } else {
          player.sendMessage(
              Message.parse(
                  "check.item.unclaimed",
                  request.getId(),
                  sdf.format(calendar.getTime()),
                  (online) ? ChatColor.GREEN : ChatColor.RED,
                  parent.getTableHandler().getUser().getUserFromId(request.getUserId()).getName(),
                  substring));
        }
      }

      if (!isModerator) {
        return true;
      }
      int reqs_left = pager.getTotalRowCount() - (page) * pager.getPageSize();
      if (reqs_left > 0) {
        player.sendMessage(Message.parse("check.more", reqs_left, page + 1));
      }

    } catch (Exception e) {
      e.printStackTrace();
      player.sendMessage(Message.parse("general.error.internal"));
    }

    return true;
  }
Пример #7
0
 public static int getTotalPrivatePageCount(String user, int pageSize) {
   PagingList<Scenario> pagingList =
       find.where().eq("members.email", user).findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Пример #8
0
 public static List<Scenario> findInvolvingUser(String user, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where().eq("members.email", user).findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }