Ignore:
Timestamp:
May 19, 2020, 2:24:30 PM (2 years ago)
Author:
Nicklas Nordborg
Message:

Merge BASE 3.16.1 to the trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/www/views/itemlists/index.jsp

    r7747 r7813  
    229229      Item memberType = Item.valueOf(request.getParameter("memberType"));
    230230      list = ItemList.getNew(dc, memberType);
     231      if (Values.getBoolean(request.getParameter("private")))
     232      {
     233        list.setProjectKey(null);
     234        list.setItemKey(null);
     235      }
    231236      dc.saveItem(list);
    232237     
     
    552557    dc.commit();
    553558  }
     559  else if ("AddMembers".equals(cmd))
     560  {
     561    dc = sc.newDbControl();
     562    ItemList list = ItemList.getById(dc, Values.getInt(itemId));
     563    String subContext = Values.getString(request.getParameter("subContext"), "");
     564    final int maxRecent = Base.getMaxRecent(sc);
     565   
     566    ItemContext memberContext = sc.getCurrentContext(list.getMemberType(), subContext);
     567    memberContext.setRecent(Item.ITEMLIST, list, "AddMembers", maxRecent);
     568    ItemQuery<? extends Listable> query = memberContext.getQuery();
     569    String source = request.getParameter("source");
     570    if ("all".equals(source))
     571    {
     572      query.setFirstResult(0);
     573      query.setMaxResults(-1);
     574    }
     575    else if ("selected".equals(source))
     576    {
     577      query.setFirstResult(0);
     578      query.setMaxResults(-1);
     579      Integer[] itemIds = Values.getInt(request.getParameter("items").split(","));
     580      query.restrict(
     581        Restrictions.in(
     582          Hql.property("id"),
     583          Expressions.parameter("selectedItems")
     584        )
     585      );
     586      query.setParameter("selectedItems", Arrays.asList(itemIds), Type.INT);     
     587    }
     588    // else -- no modifications to the query mean that we only get the current page
     589
     590    int count = list.add(query.iterate(dc));
     591    dc.commit();
     592    message = count + " members added to list";
     593  }
    554594  else
    555595  {
Note: See TracChangeset for help on using the changeset viewer.