Changeset 5370
- Timestamp:
- Jun 23, 2010, 2:51:50 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/src/docbook/userdoc/project_permission.xml
r5319 r5370 315 315 <listitem> 316 316 <para> 317 When you create new items, they are automatically added to the active318 project so319 there is almost noneed to share items manually. All317 When you create new items, they are automatically shared 318 using the settings from the active project. There is almost no 319 need to share items manually. All 320 320 you have to remember is to set an active project, and 321 321 this is easy accessible from the … … 355 355 You should always, with few exceptions, have a project active 356 356 when you work with BASE. The most important reason is that 357 new items will automatically be included in the active project. 358 This considerably reduces the time needed for managing access 359 permissions. Without an active project you would have to manually 357 new items will automatically be shared using the settings in 358 the active project. This considerably reduces 359 the time needed for managing access permissions. Without an 360 active project you would have to manually 360 361 set the permission on all items you create. If you have hundreds 361 362 of items this is a time-consuming and boring task best to be … … 464 465 <para> 465 466 When a project is active all new items you create are automatically 466 shared to this project. By default the permission are set to 467 shared using the settings from the active project. If the active project 468 has a permission template the permissions from the template are copied 469 to the new item. If the project doesn't have a permission template, the 470 new item is shared to the active project with the configured default 471 level. By default, projects doesn't have a permission template 472 and the default permissions are set to 467 473 <emphasis>read</emphasis>, <emphasis>use</emphasis>, 468 474 <emphasis>write</emphasis> and <emphasis>delete</emphasis>. It is … … 756 762 757 763 </sect1> 758 764 765 <sect1 id="project_permission.templates"> 766 <title>Permission templates</title> 767 768 <para> 769 A <emphasis>permission template</emphasis> is a pre-defined set of permissions 770 for users, groups and/or projects. The template makes it easy to quickly share 771 items to multiple users, groups and projects, possible with different permissions 772 for everyone. There are three major use-cases were permission templates are useful: 773 </para> 774 775 <itemizedlist> 776 <listitem> 777 <para> 778 A permission template can be associated with project. When the project is selected 779 as the active project, the permissions from the template are copied to any new items 780 that are created. Note that the new items may or may not be shared with the active 781 project, depending on the settings in the permission template. 782 </para> 783 </listitem> 784 <listitem> 785 <para> 786 Permission templates can be selected in the <link linkend="webclient.items.share">share dialog</link>, 787 making it easier to manually share items to multiple users, 788 groups and projects in just a few clicks. 789 </para> 790 </listitem> 791 <listitem> 792 <para> 793 Permission templates can be used with some batch item importers, making it easier 794 for administrators which only needs a single data file even if the data belong to 795 different projects. 796 </para> 797 </listitem> 798 </itemizedlist> 799 800 <para> 801 Permission templates are managed from the <menuchoice><guimenu>View</guimenu> 802 <guisubmenu>Permission templates</guisubmenu></menuchoice> menu. The template is 803 a very simple item that only has a name (required) and a description (optional). 804 We recommend that the names of the templates are kept unique, but this is not 805 enforced by BASE. To assign permissions to the template use the 806 <guibutton>Set permissions</guibutton> button. This is the same dialog as the 807 <link linkend="webclient.items.share">share dialog</link>. 808 </para> 809 810 <note> 811 <title>Permissions are copied</title> 812 <para> 813 When a permission template is used the permissions are <emphasis>copied</emphasis> 814 to the items. Modifications to the template that are made afterwards doesn't 815 affect the permissions for the items on which the template was used. 816 </para> 817 </note> 818 </sect1> 759 819 </chapter> -
trunk/doc/src/docbook/userdoc/webclient.xml
r5319 r5370 1216 1216 to other users. This is because whenever you work with an active 1217 1217 project each new item you create will automatically be shared 1218 to that project. In most cases, this is all you need. 1218 according to the settings of that project. In most cases, this 1219 is all you need. 1219 1220 </para> 1220 1221 … … 1271 1272 </para> 1272 1273 1274 <para> 1275 The <guilabel>Permission templates</guilabel> part of the list 1276 is always empty to begin with. 1277 </para> 1278 1273 1279 </listitem> 1274 1280 </varlistentry> … … 1286 1292 You can select more than one user, group or project 1287 1293 and change the permissions for all of them at once. 1294 </para> 1295 <para> 1296 The permission boxes are disabled if a permission template 1297 is selected. The permissions are already part of the template 1298 and can't be changed here. 1288 1299 </para> 1289 1300 </listitem> … … 1348 1359 projects that already have access to the items. 1349 1360 </para> 1361 </listitem> 1362 </varlistentry> 1363 1364 <varlistentry> 1365 <term><guibutton>Templates</guibutton></term> 1366 <listitem> 1367 <para> 1368 Opens a pop-up window that allows you to select 1369 permission templates. In the pop-up window, mark 1370 one or more templates and click on the &gbOk; 1371 button. Unless you are an administrator, the pop-up window 1372 will only list templates that you are allowed to use. It will 1373 not list templates that have already been added. 1374 </para> 1375 1376 <note> 1377 <para> 1378 The permissions from the selected templates are <emphasis>copied</emphasis> 1379 to the items when the access permissions are saved. If you re-open the share dialog, 1380 the actual permissions are shown and the permission templates 1381 section is empty. Modifying the permission template later doesn't 1382 affect the permissions on existing items. See <xref linkend="project_permission.templates" /> 1383 for more information about permission templates. 1384 </para> 1385 </note> 1386 1350 1387 </listitem> 1351 1388 </varlistentry> -
trunk/src/core/net/sf/basedb/core/MultiPermissions.java
r5060 r5370 328 328 329 329 /** 330 Merge the permissions from the given item key keeping those 331 that has already been set. 332 333 @param itemKey An item key (if null, this method simply returns) 334 @since 2.16 335 @see UserPermissions#merge(ItemKey) 336 @see GroupPermissions#merge(ItemKey) 337 */ 338 public void merge(ItemKey itemKey) 339 { 340 if (itemKey == null) return; 341 for (UserPermissions up : userPermissions.values()) 342 { 343 up.merge(itemKey); 344 } 345 for (GroupPermissions gp : groupPermissions.values()) 346 { 347 gp.merge(itemKey); 348 } 349 } 350 351 /** 352 Merge the permissions from the given project key keeping those 353 that has already been set. 354 355 @param projectKey An project key (if null, this method simply returns) 356 @since 2.16 357 @see ProjectPermissions#merge(ProjectKey) 358 */ 359 public void merge(ProjectKey projectKey) 360 { 361 if (projectKey == null) return; 362 for (ProjectPermissions pp : projectPermissions.values()) 363 { 364 pp.merge(projectKey); 365 } 366 } 367 368 /** 330 369 Get a query that returns all users appearing in at least one of 331 370 the item keys. The query will not return users that the logged in -
trunk/www/common/share/share.jsp
r4889 r5370 206 206 } 207 207 %> 208 Link.addNewSection(members, new Section('T', 'Permission templates')); 208 209 } 209 210 // Submit the form … … 214 215 frm.modifiedGroups.value = Link.exportModified(frm, 'G').join(','); 215 216 frm.modifiedProjects.value = Link.exportModified(frm, 'P').join(','); 217 frm.permissionTemplates.value = Link.getListIds(frm.members, 'T').join(','); 216 218 frm.submit(); 217 219 } … … 261 263 return s; 262 264 } 263 function showPermissions(permissionCode, disabled) 264 { 265 function showPermissions(permissionCode, isEveryone, isTemplate) 266 { 267 var disabled = isTemplate || (isEveryone && !share_to_everyone); 265 268 var frm = document.forms['share']; 266 269 frm['read'].checked = permissionCode & <%=READ_CODE%>; … … 276 279 frm['set_owner'].disabled = disabled; 277 280 frm['set_permission'].disabled = disabled; 278 if ( disabled)281 if (isEveryone && !share_to_everyone) 279 282 { 280 283 Main.show('share_disabled'); … … 299 302 { 300 303 var item = option.item; 301 var disabled = item. id == everyone_id && item.type == 'G' && !share_to_everyone;304 var disabled = item.type == 'T' || (item.id == everyone_id && item.type == 'G' && !share_to_everyone); 302 305 if (!disabled) 303 306 { … … 316 319 if (item && item.id) 317 320 { 318 var disabled = item.id == everyone_id && item.type == 'G' && !share_to_everyone; 319 showPermissions(item.value, disabled); 321 var isTemplate = item.type == 'T'; 322 var isEveryone = item.id == everyone_id && item.type == 'G'; 323 showPermissions(item.value, isEveryone, isTemplate); 320 324 } 321 325 } … … 334 338 if (!item) item = new Item('U', userId, name+' ['+permissionString+']', permissionCode, 0); 335 339 Link.addItem(document.forms['share'].members, item); 340 membersOnChange(); 336 341 } 337 342 function addGroupsOnClick() … … 356 361 if (!item) item = new Item('G', groupId, name+' ['+permissionString+']', permissionCode, 0); 357 362 Link.addItem(document.forms['share'].members, item); 363 membersOnChange(); 358 364 } 359 365 function addProjectsOnClick() … … 370 376 if (!item) item = new Item('P', projectId, name+' ['+permissionString+']', permissionCode, 0); 371 377 Link.addItem(document.forms['share'].members, item); 378 membersOnChange(); 379 } 380 function addPermissionTemplateOnClick() 381 { 382 var ids = Link.getListIds(document.forms['share'].members, 'T'); 383 var excludes = ids.join(','); 384 Main.openPopup('../../views/permissiontemplates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addPermissionTemplateCallback&permission=READ&exclude='+excludes, 'AddPermissionTemplates', 1000, 700); 385 } 386 function addPermissionTemplateCallback(templateId, name) 387 { 388 var item = Link.getItem('T', templateId); 389 if (!item) item = new Item('T', templateId, name, 0, 0); 390 Link.addItem(document.forms['share'].members, item); 391 membersOnChange(); 372 392 } 373 393 function removeOnClick() 374 394 { 375 395 Link.removeSelected(document.forms['share'].members); 396 membersOnChange(); 376 397 } 377 398 </script> … … 395 416 <input type="hidden" name="modifiedGroups" value=""> 396 417 <input type="hidden" name="modifiedProjects" value=""> 418 <input type="hidden" name="permissionTemplates" value=""> 397 419 </td> 398 420 … … 429 451 /></td></tr> 430 452 <tr><td><base:button 453 onclick="addPermissionTemplateOnClick()" 454 title="Templates…" 455 tooltip="Add permission templates" 456 image="add.png" 457 disabled="<%=!writePermission %>" 458 /></td></tr> 459 <tr><td><base:button 431 460 onclick="removeOnClick()" 432 461 title="Remove" -
trunk/www/common/share/submit_share.jsp
r5136 r5370 47 47 import="net.sf.basedb.core.Group" 48 48 import="net.sf.basedb.core.Project" 49 import="net.sf.basedb.core.PermissionTemplate" 49 50 import="net.sf.basedb.clients.web.Base" 50 51 import="net.sf.basedb.clients.web.PermissionUtil" … … 106 107 } 107 108 } 109 110 String[] permissionTemplates = Values.getString(request.getParameter("permissionTemplates")).split(","); 111 for (int i = 0; i < permissionTemplates.length; ++i) 112 { 113 int permissionTemplateId = Values.getInt(permissionTemplates[i], -1); 114 if (permissionTemplateId != -1) 115 { 116 PermissionTemplate template = PermissionTemplate.getById(dc, permissionTemplateId); 117 mp.merge(template.getItemKey()); 118 mp.merge(template.getProjectKey()); 119 } 120 } 121 122 108 123 mp.updateKeys(dc, recursive); 109 124 sc.reloadPermissions(); -
trunk/www/include/menu.jsp
r5361 r5370 379 379 final boolean hasProjects = !sc.hasPermission(Permission.DENIED, Item.PROJECT); 380 380 final boolean createProjects = sc.hasPermission(Permission.CREATE, Item.PROJECT); 381 final boolean hasPermissionTemplates = !sc.hasPermission(Permission.DENIED, Item.PERMISSIONTEMPLATE); 381 382 382 383 final boolean hasMessages = !sc.hasPermission(Permission.DENIED, Item.MESSAGE); … … 437 438 tooltip="Manage projects" 438 439 enabled="<%=hasProjects%>" 440 /> 441 <m:menuitem 442 title="Permission templates" 443 onclick="<%="Menu.openUrl('"+root+"views/permissiontemplates/index.jsp?ID="+ID+"')"%>" 444 tooltip="Manage permission templates" 445 enabled="<%=hasPermissionTemplates%>" 439 446 /> 440 447 <m:menuitem -
trunk/www/include/scripts/main.js
r5365 r5370 521 521 this.controllers['MESSAGE'] = { url:'my_base/messages/index.jsp', width:600, height:420, popup:true, edit:false }; 522 522 this.controllers['PROJECT'] = { url:'my_base/projects/index.jsp', width:600, height:460 }; 523 this.controllers['PERMISSIONTEMPLATE'] = { url:'views/permissiontemplates/index.jsp', width:450, height:280 }; 523 524 this.controllers['FILE'] = { url:'filemanager/index.jsp', width:560, height:420 }; 524 525 this.controllers['FILESERVER'] = { url:'filemanager/fileservers/index.jsp', width:600, height:460 }; -
trunk/www/my_base/projects/edit_project.jsp
r4889 r5370 39 39 import="net.sf.basedb.core.Platform" 40 40 import="net.sf.basedb.core.PlatformVariant" 41 import="net.sf.basedb.core.Include" 42 import="net.sf.basedb.core.PermissionTemplate" 41 43 import="net.sf.basedb.core.User" 42 44 import="net.sf.basedb.core.Group" … … 93 95 String title = null; 94 96 Project project = null; 95 97 96 98 // Query to retrieve child groups 97 99 ItemQuery<Group> groupQuery = null; … … 109 111 PlatformVariant currentVariant = null; 110 112 RawDataType currentRawDataType = null; 111 113 boolean readCurrentPermissionTemplate = true; 114 PermissionTemplate currentPermissionTemplate = null; 115 116 List<PermissionTemplate> recentPermissionTemplates = (List<PermissionTemplate>)cc.getRecent(dc, Item.PERMISSIONTEMPLATE); 117 112 118 if (itemId == 0) 113 119 { 114 120 title = "Create project"; 115 121 cc.removeObject("item"); 122 currentPermissionTemplate = Base.getFirstMatching(dc, PermissionTemplate.getQuery(), "name", cc.getPropertyFilter("permissionTemplate.name")); 116 123 } 117 124 else … … 140 147 if (currentRawDataType == null && currentPlatform != null) currentRawDataType = currentPlatform.getRawDataType(); 141 148 if (currentRawDataType == null) currentRawDataType = project.getDefaultRawDataType(); 142 149 150 try 151 { 152 currentPermissionTemplate = project.getPermissionTemplate(); 153 } 154 catch (PermissionDeniedException ex) 155 { 156 readCurrentPermissionTemplate = false; 157 } 158 143 159 groupQuery = project.getGroups(); 144 160 groupQuery.include(Include.ALL); … … 173 189 final String requiredClazz = "class=\"text required\""; 174 190 %> 175 176 <%@page import="net.sf.basedb.core.Include"%> 177 <base:page type="popup" title="<%=title%>"> 191 <base:page type="popup" title="<%=title%>"> 178 192 <base:head scripts="tabcontrol.js,linkitems.js,parameters.js,platforms.js" styles="tabcontrol.css,parameters.css"> 179 193 <script language="JavaScript"> … … 223 237 initDefaults(); 224 238 platformOnChange(); 239 permissionTemplateOnChange(); 225 240 showPermissions(frm.autoPermissions.value, 'auto_'); 226 241 } … … 441 456 frm.autoPermissions.value = getPermissionCode('auto_'); 442 457 } 443 458 459 function selectPermissionTemplateOnClick() 460 { 461 var frm = document.forms['project']; 462 var url = '../../views/permissiontemplates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setPermissionTemplateCallback'; 463 if (frm.permissiontemplate_id.length > 1) 464 { 465 var id = Math.abs(parseInt(frm.permissiontemplate_id[1].value)); 466 url += '&item_id='+id; 467 } 468 Main.openPopup(url, 'SelectPermissionTemplate', 1000, 700); 469 } 470 function setPermissionTemplateCallback(id, name) 471 { 472 var frm = document.forms['project']; 473 var list = frm.permissiontemplate_id; 474 if (list.length < 2 || list[1].value == '0') // > 475 { 476 Forms.addListOption(list, 1, new Option()); 477 } 478 list[1].value = id; 479 list[1].text = name; 480 list.selectedIndex = 1; 481 permissionTemplateOnChange(); 482 } 483 function permissionTemplateOnChange() 484 { 485 var frm = document.forms['project']; 486 var hasTemplate = frm.permissiontemplate_id.selectedIndex > 0; 487 frm.auto_read.disabled = hasTemplate; 488 frm.auto_use.disabled = hasTemplate; 489 frm.auto_write.disabled = hasTemplate; 490 frm.auto_delete.disabled = hasTemplate; 491 frm.auto_set_owner.disabled = hasTemplate; 492 frm.auto_set_permission.disabled = hasTemplate; 493 } 444 494 function membersOnChange() 445 495 { … … 656 706 <td class="prompt">Default permissions</td> 657 707 <td> 708 <base:select 709 id="permissiontemplate_id" 710 clazz="selectionlist" 711 required="false" 712 current="<%=currentPermissionTemplate%>" 713 denied="<%=!readCurrentPermissionTemplate%>" 714 recent="<%=recentPermissionTemplates%>" 715 newitem="<%=project == null%>" 716 unselectedtext="- select a template or specify below -" 717 onselect="selectPermissionTemplateOnClick()" 718 onchange="permissionTemplateOnChange()" 719 /> 720 658 721 <input type="checkbox" checked name="auto_read" onClick="autoPermissionsOnClick('auto_read')">Read<br> 659 722 <input type="checkbox" checked name="auto_use" onClick="autoPermissionsOnClick('auto_use')">Use<br> … … 723 786 </t:tab> 724 787 725 <t:tab id="defaults" title="Default s" helpid="project.edit.defaults">788 <t:tab id="defaults" title="Default items" helpid="project.edit.defaults"> 726 789 <table class="form" cellspacing="2" border="0" cellpadding="0" width="100%"> 727 790 <tr valign="top"> -
trunk/www/my_base/projects/index.jsp
r5060 r5370 38 38 import="net.sf.basedb.core.ItemResultIterator" 39 39 import="net.sf.basedb.core.Permission" 40 import="net.sf.basedb.core.PermissionTemplate" 40 41 import="net.sf.basedb.core.ItemContext" 41 42 import="net.sf.basedb.core.MultiPermissions" … … 133 134 // Update the properties on an item (will close the popup) 134 135 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); 136 final int maxRecent = Base.getMaxRecent(sc); 135 137 dc = sc.newDbControl(); 136 138 Project project = (Project)cc.getObject("item"); … … 149 151 project.setAutoPermission(PermissionUtil.getPermissions(Values.getInt(request.getParameter("autoPermissions"), 31))); 150 152 project.setDescription(Values.getStringOrNull(request.getParameter("description"))); 153 154 int permissionTemplateId = Values.getInt(request.getParameter("permissiontemplate_id"), -1); 155 if (permissionTemplateId >= 0) // < 0 = denied or unchanged 156 { 157 PermissionTemplate pt = permissionTemplateId == 0 ? null : PermissionTemplate.getById(dc, permissionTemplateId); 158 project.setPermissionTemplate(pt); 159 if (pt != null) cc.setRecent(pt, maxRecent); 160 } 151 161 152 162 // Members tab -
trunk/www/my_base/projects/list_projects.jsp
r4889 r5370 228 228 datatype="string" 229 229 title="Owner" 230 sortable="true" 231 filterable="true" 232 exportable="true" 233 /> 234 <tbl:columndef 235 id="permissionTemplate" 236 property="permissionTemplate.name" 237 datatype="string" 238 title="Default permissions" 230 239 sortable="true" 231 240 filterable="true" … … 419 428 enablePropertyLink="<%=mode.hasPropertyLink()%>" 420 429 /></tbl:cell> 430 <tbl:cell column="permissionTemplate" 431 ><base:propertyvalue 432 item="<%=item%>" 433 property="permissionTemplate" 434 enableEditLink="<%=mode.hasEditLink()%>" 435 enablePropertyLink="<%=mode.hasPropertyLink()%>" 436 nulltext="<%=PermissionUtil.getFullPermissionNames(item.getAutoPermission())%>" 437 /></tbl:cell> 421 438 <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" /> 422 439 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> -
trunk/www/my_base/projects/view_project.jsp
r5045 r5370 268 268 <tr> 269 269 <td class="prompt">Default permissions</td> 270 <td><%=PermissionUtil.getFullPermissionNames(project.getAutoPermission())%></td> 270 <td><base:propertyvalue item="<%=project%>" property="permissionTemplate" 271 nulltext="<%=PermissionUtil.getFullPermissionNames(project.getAutoPermission())%>" /></td> 271 272 </tr> 272 273 <tr>
Note: See TracChangeset
for help on using the changeset viewer.