Changeset 6428


Ignore:
Timestamp:
Mar 3, 2014, 3:53:29 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #1599: Convert authentication plug-in system to an extension point

Added a boolean flag to extended-properties.xml file to make it possible to mark some properties as editable by an administrator only.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/src/docbook/appendix/extended_properties.xml

    r5782 r6428  
    165165         insert="true"
    166166         averagemethod="max"
     167         restricted-edit="false"
    167168         description="An extra property for all reporters"
    168169      >
     
    315316        </row>
    316317        <row>
     318          <entry>restricted-edit</entry>
     319          <entry>no</entry>
     320          <entry>
     321            Allowed values are <constant>false</constant> (default) and
     322            <constant>true</constant>. If set, there is some restriction
     323            on who may change the values. This is currently only implemented
     324            for users. If the property is restricted only an administrator is allowed
     325            to change the value, not the user itself.
     326          </entry>
     327        </row>
     328        <row>
    317329          <entry>averagemethod</entry>
    318330          <entry>no</entry>
  • trunk/src/core/net/sf/basedb/core/ClonableProperty.java

    r6124 r6428  
    250250    super(propertyName, title, description, column,
    251251      valueType, length, nullable, true, true,
    252       averageMethod, null);
     252      false, averageMethod, null);
    253253    this.isExtendedProperty = false;
    254254    this.isMandatory = isMandatory;
     
    263263    super(p.getName(), p.getTitle(), p.getDescription(), p.getColumn(),
    264264      p.getType(), p.getLength(), p.isNullable(), true, true,
    265       p.getAverageMethod(), null);
     265      false, p.getAverageMethod(), null);
    266266    this.isExtendedProperty = true;
    267267    this.isMandatory = false;
     
    278278    super(propertyName, d.getTitle(), d.getDescription(), d.getColumn(),
    279279      Type.fromValue(d.getValueType()), d.getLength(), d.isNullable(), true, true,
    280       AverageMethod.fromValue(d.getAverageMethod()), null);
     280      false, AverageMethod.fromValue(d.getAverageMethod()), null);
    281281    this.isExtendedProperty = d.isExtendedProperty();
    282282    this.isMandatory = d.isMandatory();
  • trunk/src/core/net/sf/basedb/core/ExtendedProperties.java

    r5679 r6428  
    264264      boolean insertable = XMLUtil.getBooleanAttribute(property, "insert", true);
    265265      boolean updateable = XMLUtil.getBooleanAttribute(property, "update", true);
     266      boolean restrictedEdit = XMLUtil.getBooleanAttribute(property, "restricted-edit", false);
    266267      String avgMethod = property.getAttributeValue("averagemethod");
    267268      Formula.AverageMethod averageMethod = null;
     
    304305        }
    305306      }
    306       properties.add(new ExtendedProperty(name, title, description, column, type, length, nullable, insertable, updateable, averageMethod, epLinks));
     307      properties.add(new ExtendedProperty(name, title, description, column, type, length, nullable, insertable, updateable, restrictedEdit, averageMethod, epLinks));
    307308    }
    308309  }
  • trunk/src/core/net/sf/basedb/core/ExtendedProperty.java

    r6127 r6428  
    7070  private final boolean insertable;
    7171  private final boolean updateable;
     72  private final boolean restrictedEdit;
    7273  private final Formula.AverageMethod averageMethod;
    7374  private final List<ExtendedPropertyLinker> linkers;
     
    7980  ExtendedProperty(String name, String title, String description, String column,
    8081    Type type, int length, boolean nullable, boolean insertable, boolean updateable,
     82    boolean restrictedEdit,
    8183    Formula.AverageMethod averageMethod, List<ExtendedPropertyLinker> linkers)
    8284  {
     
    9092    this.insertable = insertable;
    9193    this.updateable = updateable;
     94    this.restrictedEdit = restrictedEdit;
    9295    this.averageMethod = averageMethod;
    9396    this.linkers = linkers;
     
    179182  {
    180183    return updateable;
     184  }
     185 
     186  /**
     187    Check if the value of this property is restricted for editing or not.
     188    This typically means that the logged in user must have a specific permission
     189    in order to change the value. To begin with restricted editing is only
     190    used for {@link User} items to lock some properties for non-administrator
     191    editing.
     192    @since 3.3
     193  */
     194  public boolean isRestrictedEdit()
     195  {
     196    return restrictedEdit;
    181197  }
    182198
  • trunk/src/core/net/sf/basedb/core/RawDataProperty.java

    r4889 r6428  
    4444    Type type, int length, boolean nullable, Formula.AverageMethod averageMethod, int channel)
    4545  {
    46     super(name, title, description, column, type, length, nullable, true, false, averageMethod, null);
     46    super(name, title, description, column, type, length, nullable, true, false, false, averageMethod, null);
    4747    this.channel = channel;
    4848  }
  • trunk/src/core/net/sf/basedb/core/User.java

    r6127 r6428  
    817817    @param value The value the extended property should have
    818818    @throws PermissionDeniedException If the logged in user doesn't
    819       have @link {Permission#WRITE} permission for the user.
     819      have @link {Permission#RESTRICTED_WRITE} permission for the user.
    820820    @since 2.4
    821821  */
    822822  public void setExtended(String name, Object value)
    823823  {
    824     checkPermission(Permission.RESTRICTED_WRITE);
     824    ExtendedProperty ep = ExtendedProperties.getProperty("UserData", name);
     825    Permission permission = (ep != null && ep.isRestrictedEdit()) ? Permission.WRITE : Permission.RESTRICTED_WRITE;
     826    checkPermission(permission);
    825827    getData().setExtended(name, value);
    826828  }
  • trunk/src/core/net/sf/basedb/core/dtd/extended-properties.dtd

    r5679 r6428  
    4242  update (true|false) "true"
    4343  averagemethod (none|arithmetic_mean|geometric_mean|quadratic_mean|min|max) #IMPLIED
     44  restricted-edit (true|false) "false"
    4445>
    4546
  • trunk/www/include/scripts/main-2.js

    r6422 r6428  
    26652665  strings.encodeTags = function(value)
    26662666  {
    2667     var encoded = value
     2667    var encoded = value;
    26682668    encoded = encoded.replace(/\&/g, '&amp;');
    26692669    encoded = encoded.replace(/\</g, '&lt;');
  • trunk/www/include/styles/main.css

    r6416 r6428  
    578578
    579579/* Disabled input fields are grayed out and inactive */
    580 input:disabled, textarea:disabled, select:disabled
     580input:disabled, textarea:disabled, select:disabled, input.disabled
    581581{
    582582  background: #F8F8F8;
  • trunk/www/my_base/user/settings.jsp

    r6175 r6428  
    226226            Object value = user == null ? cc.getPropertyValue(name) : user.getExtended(name);
    227227            String isRequired = required ? "class=\"required\"" : "";
     228            final String isDisabled = ep.isRestrictedEdit() ? "disabled" : "";
    228229            boolean addZoom = false;
    229230            %>
     
    235236              {
    236237                %>
    237                 <input <%=isRequired%> <%=ifDisabled %> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
     238                <input <%=isRequired%> <%=isDisabled %> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
    238239                  value="<%=value == null ? "" : value%>" style="width: 15em;" maxlength="20">
    239240                <%
     
    242243              {
    243244                %>
    244                 <input <%=isRequired%> <%=ifDisabled%> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
     245                <input <%=isRequired%> <%=isDisabled%> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
    245246                  value="<%=value == null ? "" : value%>" style="width: 15em;" maxlength="20">
    246247                <%
     
    249250              {
    250251                %>
    251                 <input <%=isRequired%> <%=ifDisabled%> type="text" name="<%=fieldName%>"
     252                <input <%=isRequired%> <%=isDisabled%> type="text" name="<%=fieldName%>"
    252253                  value="<%=HTML.encodeTags((String)value)%>"
    253254                  maxlength="<%=ep.getLength()%>">
     
    258259                addZoom = true;
    259260                %>
    260                 <textarea <%=isRequired%> <%=ifDisabled%> name="<%=fieldName%>" id="<%=fieldName%>" rows="6" 
     261                <textarea <%=isRequired%> <%=isDisabled%> name="<%=fieldName%>" id="<%=fieldName%>" rows="6" 
    261262                  ><%=HTML.encodeTags((String)value)%></textarea>
    262263                <%
     
    288289                <tr>
    289290                <td>
    290                   <input <%=isRequired%> <%=ifDisabled%> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
     291                  <input <%=isRequired%> <%=isDisabled%> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
    291292                    value="<%=dateFormatter.format((Date)value)%>" style="width: 15em;"
    292293                    maxlength="20" title="Enter date in format: <%=dateFormat%>"
     
    313314                <tr>
    314315                <td>
    315                   <input <%=isRequired%> <%=ifDisabled%> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
     316                  <input <%=isRequired%> <%=isDisabled%> type="text" name="<%=fieldName%>" id="<%=fieldName%>"
    316317                    value="<%=dateTimeFormatter.format((Date)value)%>" style="width: 15em;"
    317318                    maxlength="20" title="Enter timestamp in format: <%=dateTimeFormat%>"
  • trunk/www/my_base/user/submit_user.jsp

    r6166 r6428  
    9999      for (ExtendedProperty ep : extendedProperties)
    100100      {
     101        if (ep.isRestrictedEdit()) continue;
    101102        String name = ep.getName();
    102103        Formatter formatter = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
Note: See TracChangeset for help on using the changeset viewer.