Changeset 7214


Ignore:
Timestamp:
Oct 19, 2016, 3:36:34 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2034: New permission for annotating items

Default permissions for a project now supports the "Annotate" permission. Members can be added to a project with "Annotate" permission.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/PermissionUtil.java

    r7212 r7214  
    5555      if (item.hasPermission(Permission.READ) && itemPermissions.contains(Permission.READ)) sb.append("R");
    5656      if (item.hasPermission(Permission.USE) && itemPermissions.contains(Permission.USE)) sb.append("U");
     57      if (item.hasPermission(Permission.RESTRICTED_WRITE) && itemPermissions.contains(Permission.RESTRICTED_WRITE)) sb.append("A");
    5758      if (item.hasPermission(Permission.WRITE) && itemPermissions.contains(Permission.WRITE)) sb.append("W");
    5859      if (item.hasPermission(Permission.DELETE) && itemPermissions.contains(Permission.DELETE)) sb.append("D");
     
    6465      if (item.hasPermission(Permission.READ)) sb.append("R");
    6566      if (item.hasPermission(Permission.USE)) sb.append("U");
     67      if (item.hasPermission(Permission.RESTRICTED_WRITE)) sb.append("A");
    6668      if (item.hasPermission(Permission.WRITE)) sb.append("W");
    6769      if (item.hasPermission(Permission.DELETE)) sb.append("D");
     
    99101  /**
    100102    Create a comma-separated string with "readable" permission names.
    101     @since 2.10
    102   */
    103   public static final String getFullPermissionNames(Set<Permission> permissions)
     103    @since 2.10, 3.10
     104  */
     105  public static final String getFullPermissionNames(Set<Permission> permissions, String restrictedWrite)
    104106  {
    105107    StringBuilder sb = new StringBuilder();
     
    108110      if (permissions.contains(Permission.READ)) sb.append("Read");
    109111      if (permissions.contains(Permission.USE)) sb.append(sb.length()==0 ? "Use" : ", Use");
     112      if (restrictedWrite != null && permissions.contains(Permission.RESTRICTED_WRITE))
     113      {
     114        sb.append(sb.length()==0 ? restrictedWrite : ", "+restrictedWrite);
     115      }
    110116      if (permissions.contains(Permission.WRITE)) sb.append(sb.length()==0 ? "Write" : ", Write");
    111117      if (permissions.contains(Permission.DELETE)) sb.append(sb.length()==0 ? "Delete" : ", Delete");
  • trunk/src/core/net/sf/basedb/core/Item.java

    r7212 r7214  
    7171    The item is a {@link Project}.
    7272  */
    73   PROJECT(24, "Project", "prj", Project.class, ProjectData.class, DefinedPermissions.ownable,
     73  PROJECT(24, "Project", "prj", Project.class, ProjectData.class, DefinedPermissions.ownable_annotatable,
    7474    1400),
    7575  /**
     
    10241024    private static final Set<Permission> basic = Collections.unmodifiableSet(EnumSet.of(Permission.CREATE, Permission.READ, Permission.USE, Permission.WRITE, Permission.DELETE));
    10251025    private static final Set<Permission> ownable = Collections.unmodifiableSet(EnumSet.of(Permission.CREATE, Permission.READ, Permission.USE, Permission.WRITE, Permission.DELETE, Permission.SET_OWNER));
     1026    private static final Set<Permission> ownable_annotatable = Collections.unmodifiableSet(EnumSet.of(Permission.CREATE, Permission.READ, Permission.USE, Permission.RESTRICTED_WRITE, Permission.WRITE, Permission.DELETE, Permission.SET_OWNER));
    10261027    private static final Set<Permission> shareable = Collections.unmodifiableSet(EnumSet.of(Permission.CREATE, Permission.READ, Permission.USE, Permission.WRITE, Permission.DELETE, Permission.SET_OWNER, Permission.SET_PERMISSION));
    10271028    private static final Set<Permission> shareable_annotatable = Collections.unmodifiableSet(EnumSet.of(Permission.CREATE, Permission.READ, Permission.USE, Permission.RESTRICTED_WRITE, Permission.WRITE, Permission.DELETE, Permission.SET_OWNER, Permission.SET_PERMISSION));
  • trunk/www/my_base/projects/edit_project.jsp

    r7199 r7214  
    7979private static final int READ_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.READ));
    8080private static final int USE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.USE));
     81private static final int RESTRICTED_WRITE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.RESTRICTED_WRITE));
    8182private static final int WRITE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.WRITE));
    8283private static final int DELETE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.DELETE));
     
    8990  sb.append(permissions.contains(Permission.READ) ? "R" : "-");
    9091  sb.append(permissions.contains(Permission.USE) ? "U" : "-");
     92  sb.append(permissions.contains(Permission.RESTRICTED_WRITE) ? "A" : "-");
    9193  sb.append(permissions.contains(Permission.WRITE) ? "W" : "-");
    9294  sb.append(permissions.contains(Permission.DELETE) ? "D" : "-");
     
    252254      data-read="<%=READ_CODE%>"
    253255      data-use="<%=USE_CODE%>"
     256      data-restricted-write="<%=RESTRICTED_WRITE_CODE%>"
    254257      data-write="<%=WRITE_CODE%>"
    255258      data-delete="<%=DELETE_CODE%>"
     
    296299          <input type="checkbox" id="autoUse" checked name="auto_use"
    297300            ><label for="autoUse">Use</label><br>
     301          <input type="checkbox" id="autoRestrictedWrite" name="auto_restricted_write"
     302            ><label for="autoRestrictedWrite">Annotate</label><br>
    298303          <input type="checkbox" id="autoWrite" name="auto_write"
    299304            ><label for="autoWrite">Write</label><br>
     
    340345        <input type="checkbox" id="read" checked name="read"><label for="read">Read</label><br>
    341346        <input type="checkbox" id="use" checked name="use"><label for="use">Use</label><br>
     347        <input type="checkbox" id="restricted_write" name="restricted_write"><label for="restricted_write">Annotate</label><br>
    342348        <input type="checkbox" id="write" name="write"><label for="write">Write</label><br>
    343349        <input type="checkbox" id="delete" name="delete"><label for="delete">Delete</label><br>
  • trunk/www/my_base/projects/list_projects.jsp

    r7199 r7214  
    452452                    enableEditLink="<%=mode.hasEditLink()%>"
    453453                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    454                     nulltext="<%=PermissionUtil.getFullPermissionNames(item.getAutoPermission())%>"
     454                    nulltext="<%=PermissionUtil.getFullPermissionNames(item.getAutoPermission(), "Annotate")%>"
    455455                  /></tbl:cell>
    456456                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
  • trunk/www/my_base/projects/projects.js

    r7199 r7214  
    3838      Permission.READ = Data.int('page-data', 'read');
    3939      Permission.USE = Data.int('page-data', 'use');
     40      Permission.RESTRICTED_WRITE = Data.int('page-data', 'restricted-write');
    4041      Permission.WRITE = Data.int('page-data', 'write');
    4142      Permission.DELETE = Data.int('page-data', 'delete');
     
    6263      Events.addEventHandler('read', 'click', projects.permissionsOnClick);
    6364      Events.addEventHandler('use', 'click', projects.permissionsOnClick);
     65      Events.addEventHandler('restricted_write', 'click', projects.permissionsOnClick);
    6466      Events.addEventHandler('write', 'click', projects.permissionsOnClick);
    6567      Events.addEventHandler('delete', 'click', projects.permissionsOnClick);
     
    6971      Events.addEventHandler('autoRead', 'click', projects.autoPermissionsOnClick);
    7072      Events.addEventHandler('autoUse', 'click', projects.autoPermissionsOnClick);
     73      Events.addEventHandler('autoRestrictedWrite', 'click', projects.autoPermissionsOnClick);
    7174      Events.addEventHandler('autoWrite', 'click', projects.autoPermissionsOnClick);
    7275      Events.addEventHandler('autoDelete', 'click', projects.autoPermissionsOnClick);
     
    180183    if (frm[prefix+'read'].checked) permissionCode += Permission.READ;
    181184    if (frm[prefix+'use'].checked) permissionCode += Permission.USE;
     185    if (frm[prefix+'restricted_write'].checked) permissionCode += Permission.RESTRICTED_WRITE;
    182186    if (frm[prefix+'write'].checked) permissionCode += Permission.WRITE;
    183187    if (frm[prefix+'delete'].checked) permissionCode += Permission.DELETE;
     
    192196    s += permissionCode & Permission.READ ? "R" : "-";
    193197    s += permissionCode & Permission.USE ? "U" : "-";
     198    s += permissionCode & Permission.RESTRICTED_WRITE ? "A" : "-";
    194199    s += permissionCode & Permission.WRITE ? "W" : "-";
    195200    s += permissionCode & Permission.DELETE ? "D" : "-";
     
    205210    frm[prefix+'read'].checked = permissionCode & Permission.READ;
    206211    frm[prefix+'use'].checked = permissionCode & Permission.USE;
     212    frm[prefix+'restricted_write'].checked = permissionCode & Permission.RESTRICTED_WRITE;
    207213    frm[prefix+'write'].checked = permissionCode & Permission.WRITE;
    208214    frm[prefix+'delete'].checked = permissionCode & Permission.DELETE;
     
    221227    {
    222228      frm[prefix+'write'].checked = frm[prefix+'write'].checked || frm[prefix+'delete'].checked || frm[prefix+'set_owner'].checked || frm[prefix+'set_permission'].checked;
     229      frm[prefix+'restricted_write'].checked = frm[prefix+'restricted_write'].checked || frm[prefix+'write'].checked;
    223230      frm[prefix+'use'].checked = frm[prefix+'use'].checked || frm[prefix+'write'].checked;
    224       frm[prefix+'read'].checked = frm[prefix+'read'].checked || frm[prefix+'use'].checked;
     231      frm[prefix+'read'].checked = frm[prefix+'read'].checked || frm[prefix+'use'].checked || frm[prefix+'restricted_write'].checked;
    225232    }
    226233    else
    227234    {
    228235      frm[prefix+'use'].checked = frm[prefix+'use'].checked && frm[prefix+'read'].checked;
    229       frm[prefix+'write'].checked = frm[prefix+'write'].checked && frm[prefix+'use'].checked;
     236      frm[prefix+'restricted_write'].checked = frm[prefix+'restricted_write'].checked && frm[prefix+'read'].checked;
     237      frm[prefix+'write'].checked = frm[prefix+'write'].checked && frm[prefix+'use'].checked && frm[prefix+'restricted_write'].checked;
    230238      frm[prefix+'delete'].checked = frm[prefix+'delete'].checked && frm[prefix+'write'].checked;
    231239      frm[prefix+'set_owner'].checked = frm[prefix+'set_owner'].checked && frm[prefix+'write'].checked;
     
    349357    frm.auto_read.disabled = hasTemplate;
    350358    frm.auto_use.disabled = hasTemplate;
     359    frm.auto_restricted_write.disabled = hasTemplate;
    351360    frm.auto_write.disabled = hasTemplate;
    352361    frm.auto_delete.disabled = hasTemplate;
  • trunk/www/my_base/projects/view_project.jsp

    r7199 r7214  
    223223        <th>Default permissions</th>
    224224        <td><base:propertyvalue item="<%=project%>" property="permissionTemplate"
    225           nulltext="<%=PermissionUtil.getFullPermissionNames(project.getAutoPermission())%>" /></td>
     225          nulltext="<%=PermissionUtil.getFullPermissionNames(project.getAutoPermission(), "Annotate")%>" /></td>
    226226      </tr>
    227227      <tr>
     
    302302                    visible="<%=group.isRemoved()%>"
    303303                  /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
    304                 <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
     304                <tbl:cell column="permissions"><%=PermissionUtil.getFullPermissionNames(permissions, "Annotate")%></tbl:cell>
    305305              </tbl:row>
    306306              <%
     
    317317                    visible="<%=user.isRemoved()%>"
    318318                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
    319                 <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
     319                <tbl:cell column="permissions"><%=PermissionUtil.getFullPermissionNames(permissions, "Annotate")%></tbl:cell>
    320320              </tbl:row>
    321321              <%
Note: See TracChangeset for help on using the changeset viewer.