Changeset 3448
- Timestamp:
- Jun 5, 2007, 9:34:56 AM (16 years ago)
- Location:
- branches/2.3.1
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3.1/src/core/net/sf/basedb/core/Project.java
r3045 r3448 33 33 34 34 import java.util.ArrayList; 35 import java.util.EnumSet; 35 36 import java.util.HashSet; 36 37 import java.util.List; … … 345 346 346 347 /** 348 @deprecated Use {@link #getItems(Item, int, int, Permission, Set)} instead 349 */ 350 public ResultList<Shareable> getItems(Item itemType, int firstItem, int maxItems, Permission permission) 351 { 352 return getItems(itemType, firstItem, maxItems, permission, null); 353 } 354 355 356 /** 347 357 Load the items in a project. If this project is the active project it will load 348 358 all items in the project. If this project isn't the active project it will … … 353 363 @param firstItem The index of the first item to return (0-based) 354 364 @param maxItems The maximum number of items to return, or 0 to return all items 365 @param permissions The permission the logged in user must have on the item 366 @param include Options for which items that should be included/excluded from the 367 result, or null to include all non-removed items 355 368 @return A list containing shareable items 356 369 @see SessionControl#setActiveProject(Project) 357 370 */ 358 public ResultList<Shareable> getItems(Item itemType, int firstItem, int maxItems, Permission permission) 359 { 371 public ResultList<Shareable> getItems(Item itemType, int firstItem, int maxItems, 372 Permission permission, Set<Include> include) 373 { 374 if (include == null) include = EnumSet.of(Include.NOT_REMOVED, Include.MINE, Include.OTHERS); 375 360 376 DbControl dc = getDbControl(); 361 377 SessionControl sc = dc.getSessionControl(); … … 376 392 projectKeys = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query)); 377 393 378 // Enable 'ownedBy' filter since this is not the active project 379 org.hibernate.Filter ownerFilter = HibernateUtil.enableFilter(session, "ownedBy"); 380 ownerFilter.setParameter("owner", sc.getLoggedInUserId()); 394 include.remove(Include.OTHERS); 381 395 } 382 396 else … … 409 423 keyFilter.setParameter("owner", sc.getLoggedInUserId()); 410 424 425 // Add filters for 'removed' option 426 if (!(include.contains(Include.REMOVED) && include.contains(Include.NOT_REMOVED))) 427 { 428 org.hibernate.Filter removedFilter = HibernateUtil.enableFilter(session, "isRemoved"); 429 removedFilter.setParameter("removed", include.contains(Include.REMOVED)); 430 } 431 // Add filter for 'owned by me' and 'owned by others' options 432 if (include.contains(Include.MINE) && include.contains(Include.OTHERS)) 433 { 434 // Do nothing; all items are included 435 } 436 else if (include.contains(Include.MINE)) 437 { 438 org.hibernate.Filter ownerFilter = HibernateUtil.enableFilter(session, "ownedBy"); 439 ownerFilter.setParameter("owner", sc.getLoggedInUserId()); 440 } 441 else if (include.contains(Include.OTHERS)) 442 { 443 org.hibernate.Filter otherFilter = HibernateUtil.enableFilter(session, "notOwnedBy"); 444 otherFilter.setParameter("owner", sc.getLoggedInUserId()); 445 } 446 else 447 { 448 org.hibernate.Filter denyAllFilter = HibernateUtil.enableFilter(session, "denyAll"); 449 } 450 411 451 // Query to load all shareable items 412 452 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SHARED_ITEMS"); … … 422 462 HibernateUtil.disableFilter(session, "inProject"); 423 463 HibernateUtil.disableFilter(session, "ownedBy"); 464 HibernateUtil.disableFilter(session, "notOwnedBy"); 465 HibernateUtil.disableFilter(session, "isRemoved"); 466 HibernateUtil.disableFilter(session, "denyAll"); 424 467 425 468 Class<? extends BasicData> dataClass = itemType == null ? null : itemType.getDataClass(); -
branches/2.3.1/www/my_base/projects/items/list_items.jsp
r3190 r3448 69 69 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null); 70 70 final int projectId = Values.getInt(request.getParameter("project_id")); 71 final int activeProjectId = sc.getActiveProjectId(); 71 72 final DbControl dc = sc.newDbControl(); 72 73 ResultList<Shareable> items = null; … … 78 79 { 79 80 items = project.getItems(filterItem == null ? null : Item.valueOf(filterItem), 80 cc.getPage() * cc.getRowsPerPage(), cc.getRowsPerPage(), cc.getItemPermission()); 81 cc.getPage() * cc.getRowsPerPage(), cc.getRowsPerPage(), cc.getItemPermission(), 82 cc.getInclude()); 81 83 } 82 84 catch (Throwable t) … … 147 149 Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); 148 150 } 151 function setToActive() 152 { 153 Main.openPopup('../set_active.jsp?ID=<%=ID%>&project_id=<%=projectId%>', 'ActivateProject', 300, 140); 154 } 149 155 function switchTab(tabControlId, tabId) 150 156 { … … 253 259 /> 254 260 </tbl:toolbar> 261 <% 262 if (projectId != activeProjectId) 263 { 264 %> 265 <tbl:panel> 266 <div class="error" onclick="setToActive()" style="cursor: pointer;" 267 title="Click to make this project the active project"> 268 This project is not the active project. The list can't display items 269 that are owned by other members of the project. 270 </div> 271 </tbl:panel> 272 <% 273 } 274 %> 255 275 <tbl:navigator 256 276 page="<%=cc.getPage()%>" … … 264 284 colspan="3" 265 285 onchange="presetOnChange()" 286 disablesharedto="true" 287 disableothers="<%=projectId != activeProjectId%>" 266 288 /> 267 289 </tbl:columns> -
branches/2.3.1/www/my_base/projects/set_active.jsp
r2978 r3448 28 28 import="net.sf.basedb.core.SessionControl" 29 29 import="net.sf.basedb.core.DbControl" 30 import="net.sf.basedb.core.Item" 30 31 import="net.sf.basedb.core.Project" 32 import="net.sf.basedb.core.Include" 33 import="net.sf.basedb.core.ItemContext" 31 34 import="net.sf.basedb.clients.web.Base" 32 35 import="net.sf.basedb.util.Values" … … 48 51 { 49 52 Project p = null; 50 if (projectId != 0) p = Project.getById(dc, projectId); 53 ItemContext allItems = sc.getCurrentContext(Item.PROJECT, "items"); 54 allItems.getInclude().add(Include.MINE); 55 if (projectId != 0) 56 { 57 p = Project.getById(dc, projectId); 58 allItems.getInclude().add(Include.OTHERS); 59 } 51 60 sc.setActiveProject(p); 52 61 sc.setUserClientSetting("projects.lastactive", projectId == 0 ? null : Integer.toString(projectId));
Note: See TracChangeset
for help on using the changeset viewer.