Changeset 2916
- Timestamp:
- Nov 15, 2006, 11:07:43 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/PermissionUtil.java
r2664 r2916 82 82 if (item.hasPermission(Permission.WRITE) && itemPermissions.contains(Permission.WRITE)) sb.append(sb.length()==0 ? "Write" : ", Write"); 83 83 if (item.hasPermission(Permission.DELETE) && itemPermissions.contains(Permission.DELETE)) sb.append(sb.length()==0 ? "Delete" : ", Delete"); 84 if (item.hasPermission(Permission.SET_OWNER) && itemPermissions.contains(Permission.SET_OWNER)) sb.append(sb.length()==0 ? " Change owner" : ", Change owner");84 if (item.hasPermission(Permission.SET_OWNER) && itemPermissions.contains(Permission.SET_OWNER)) sb.append(sb.length()==0 ? "Take ownership" : ", Take ownership"); 85 85 if (item.hasPermission(Permission.SET_PERMISSION) && itemPermissions.contains(Permission.SET_PERMISSION)) sb.append(sb.length()==0 ? "Change permisson" : ", Change permission"); 86 86 } -
trunk/src/core/net/sf/basedb/core/Ownable.java
r2304 r2916 70 70 have permission to change the owner on the item 71 71 @throws InvalidDataException If the owner is null 72 @see #takeOwnership() 72 73 */ 73 74 public void setOwner(User owner) 74 75 throws PermissionDeniedException, InvalidDataException; 75 76 77 /** 78 Take ownership of the item. 79 @throws PermissionDeniedException If the logged in user doesn't have 80 permission to take ownership 81 @since 2.2 82 */ 83 public void takeOwnership() 84 throws PermissionDeniedException; 85 86 /** 87 Check if the logged in user is the owner of this item or not. 88 @return TRUE if the logged in user is the owner, FALSE otherwise 89 @since 2.2 90 */ 91 public boolean isOwner(); 92 76 93 } -
trunk/src/core/net/sf/basedb/core/OwnedItem.java
r2304 r2916 63 63 OwnableUtil.setOwner(getData(), owner); 64 64 } 65 public void takeOwnership() 66 throws PermissionDeniedException 67 { 68 checkPermission(Permission.SET_OWNER); 69 DbControl dc = getDbControl(); 70 getData().setOwner(HibernateUtil.loadData( 71 dc.getHibernateSession(), UserData.class, dc.getSessionControl().getLoggedInUserId())); 72 } 73 public boolean isOwner() 74 { 75 return getData().getOwner().getId() == getSessionControl().getLoggedInUserId(); 76 } 65 77 // ------------------------------------------- 66 78 -
trunk/www/admin/plugindefinitions/edit_plugin.jsp
r2854 r2916 817 817 <input type="checkbox" name="grant_write" onClick="permissionOnClick(this)">Write<br> 818 818 <input type="checkbox" name="grant_delete" onClick="permissionOnClick(this)">Delete<br> 819 <input type="checkbox" name="grant_set_owner" onClick="permissionOnClick(this)"> Set owner<br>819 <input type="checkbox" name="grant_set_owner" onClick="permissionOnClick(this)">Take ownership<br> 820 820 <input type="checkbox" name="grant_set_permission" onClick="permissionOnClick(this)">Set permission 821 821 </td> … … 827 827 <input type="checkbox" name="deny_write" onClick="permissionOnClick(this)">Write<br> 828 828 <input type="checkbox" name="deny_delete" onClick="permissionOnClick(this)">Delete<br> 829 <input type="checkbox" name="deny_set_owner" onClick="permissionOnClick(this)"> Set owner<br>829 <input type="checkbox" name="deny_set_owner" onClick="permissionOnClick(this)">Take ownership<br> 830 830 <input type="checkbox" name="deny_set_permission" onClick="permissionOnClick(this)">Set permission 831 831 </td> -
trunk/www/admin/plugindefinitions/view_plugin.jsp
r2854 r2916 561 561 has that permission<br> 562 562 <b>C/c</b> = Create, <b>R/r</b> = Read, <b>U/u</b> = Use, 563 <b>W/w</b> = Write, <b>D/d</b> = Delete, <b>O/o</b> = Change owner,563 <b>W/w</b> = Write, <b>D/d</b> = Delete, <b>O/o</b> = Take ownership, 564 564 <b>P/p</b> = Change permissions 565 565 </td> -
trunk/www/admin/roles/edit_role.jsp
r2753 r2916 409 409 <input type="checkbox" name="write" onClick="setPermissions(this.checked)">Write<br> 410 410 <input type="checkbox" name="delete" onClick="setPermissions(this.checked)">Delete<br> 411 <input type="checkbox" name="set_owner" onClick="setPermissions(this.checked)"> Set owner<br>411 <input type="checkbox" name="set_owner" onClick="setPermissions(this.checked)">Take ownership<br> 412 412 <input type="checkbox" name="set_permission" onClick="setPermissions(this.checked)">Set permission<br> 413 413 </td> -
trunk/www/admin/roles/view_role.jsp
r2753 r2916 288 288 <td colspan="99" class="panel"> 289 289 <b>C</b> = Create, <b>R</b> = Read, <b>U</b> = Use, 290 <b>W</b> = Write, <b>D</b> = Delete, <b>O</b> = Change owner, <b>P</b> = Change permissions290 <b>W</b> = Write, <b>D</b> = Delete, <b>O</b> = Take ownership, <b>P</b> = Change permissions 291 291 292 292 </td> -
trunk/www/biomaterials/biosources/index.jsp
r2811 r2916 40 40 import="net.sf.basedb.util.RemovableUtil" 41 41 import="net.sf.basedb.util.ShareableUtil" 42 import="net.sf.basedb.util.OwnableUtil" 42 43 import="net.sf.basedb.clients.web.Base" 43 44 import="net.sf.basedb.clients.web.WebException" … … 213 214 redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); 214 215 } 216 else if ("TakeOwnershipOfItem".equals(cmd)) 217 { 218 // Take ownership a single item and then return to the view page 219 dc = sc.newDbControl(); 220 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 221 OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null); 222 dc.commit(); 223 redirect = viewPage; 224 } 225 else if ("TakeOwnershipOfItems".equals(cmd)) 226 { 227 // Take ownership all selected items on the list page 228 dc = sc.newDbControl(); 229 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 230 int numTotal = cc.getSelected().size(); 231 int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null); 232 dc.commit(); 233 if (numTotal != numOwned) 234 { 235 message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission"; 236 } 237 redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : ""); 238 } 215 239 else if ("ExportItems".equals(cmd)) 216 240 { -
trunk/www/biomaterials/biosources/list_biosources.jsp
r2893 r2916 141 141 frm.submit(); 142 142 } 143 function takeOwnership() 144 { 145 var frm = document.forms[formId]; 146 if (Forms.numChecked(frm) == 0) 147 { 148 alert('Please select at least one item in the list'); 149 return; 150 } 151 if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.')) 152 { 153 frm.action = submitPage; 154 frm.cmd.value = 'TakeOwnershipOfItems'; 155 frm.submit(); 156 } 157 } 143 158 function shareItem(itemId) 144 159 { … … 304 319 title="Share…" 305 320 tooltip="Share the selected items" 321 /> 322 <tbl:button 323 image="take_ownership.png" 324 onclick="takeOwnership()" 325 title="Take ownership…" 326 tooltip="Take ownership of the selected items" 306 327 /> 307 328 <tbl:button -
trunk/www/biomaterials/biosources/view_biosource.jsp
r2753 r2916 80 80 final boolean deletePermission = bioSource.hasPermission(Permission.DELETE); 81 81 final boolean sharePermission = bioSource.hasPermission(Permission.SET_PERMISSION); 82 final boolean setOwnerPermission = bioSource.hasPermission(Permission.SET_OWNER); 83 final boolean isOwner = bioSource.isOwner(); 82 84 %> 83 85 … … 100 102 { 101 103 location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); 104 } 105 function takeOwnership() 106 { 107 if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.')) 108 { 109 location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>'); 110 } 102 111 } 103 112 function runPlugin(cmd) … … 152 161 title="Share…" 153 162 tooltip="<%=sharePermission ? "Share this biosource to other user, groups and projects" : "You do not have permission to share this biosource"%>" 163 /> 164 <tbl:button 165 disabled="<%=setOwnerPermission ? false : true%>" 166 image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>" 167 onclick="takeOwnership()" 168 title="Take ownership…" 169 visible="<%=!isOwner%>" 170 tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>" 154 171 /> 155 172 <tbl:button -
trunk/www/common/share/share.jsp
r2776 r2916 381 381 <input type="checkbox" name="write" onClick="permissionsOnClick('write')">Write<br> 382 382 <input type="checkbox" name="delete" onClick="permissionsOnClick('delete')">Delete<br> 383 <input type="checkbox" name="set_owner" onClick="permissionsOnClick('set_owner')"> Set owner<br>383 <input type="checkbox" name="set_owner" onClick="permissionsOnClick('set_owner')">Take ownership<br> 384 384 <input type="checkbox" name="set_permission" onClick="permissionsOnClick('set_permission')">Set permission<br> 385 385 </td> -
trunk/www/my_base/projects/edit_project.jsp
r2776 r2916 374 374 <input type="checkbox" name="write" onClick="permissionsOnClick('write')">Write<br> 375 375 <input type="checkbox" name="delete" onClick="permissionsOnClick('delete')">Delete<br> 376 <input type="checkbox" name="set_owner" onClick="permissionsOnClick('set_owner')"> Set owner<br>376 <input type="checkbox" name="set_owner" onClick="permissionsOnClick('set_owner')">Take ownership<br> 377 377 <input type="checkbox" name="set_permission" onClick="permissionsOnClick('set_permission')">Set permission<br> 378 378 </td>
Note: See TracChangeset
for help on using the changeset viewer.