Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-39880

add isVisible method to determine tool visibility in a site for a user



    • Type: (Deprecated) Contributed Patch
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.x
    • Component/s: Kernel
    • Labels:
    • Previous Issue Keys:


      The portal implements it's own method to check whether a given tool Placement is hidden or not. Suggest this or a similar method is implemented in the Kernel as this is a useful feature.

      Current methods from:

      public static final String TOOLCONFIG_REQUIRED_PERMISSIONS = "functions.require";

      public boolean isHidden(Placement placement)

      { if (placement == null) return true; String requiredPermissionsString = StringUtils.trimToNull(placement.getConfig().getProperty(TOOLCONFIG_REQUIRED_PERMISSIONS)); if (requiredPermissionsString == null) return false; return requiredPermissionsString.contains("site.upd"); }


      • The optional tool configuration tag "functions.require" describes a
      • set of permission lists which decide the visibility of the tool link
      • for this site user. Lists are separated by "|" and permissions within a
      • list are separated by ",". Users must have all the permissions included in
      • at least one of the permission lists.
      • For example, a value like "section.role.student,annc.new|section.role.ta"
      • would let a user with "section.role.ta" see the tool, and let a user with
      • both "section.role.student" AND "annc.new" see the tool, but not let a user
      • who only had "section.role.student" see the tool.
      • If the configuration tag is not set or is null, then all users see the tool.
        public boolean allowTool(Site site, Placement placement)
        // No way to render an opinion
        if (placement == null || site == null) return true;

      String requiredPermissionsString = placement.getConfig().getProperty(TOOLCONFIG_REQUIRED_PERMISSIONS);
      if (log.isDebugEnabled()) log.debug("requiredPermissionsString=" + requiredPermissionsString + " for " + placement.getToolId());
      if (requiredPermissionsString == null)
      return true;
      requiredPermissionsString = requiredPermissionsString.trim();
      if (requiredPermissionsString.length() == 0)
      return true;

      String[] allowedPermissionSets = requiredPermissionsString.split("
      for (int i = 0; i < allowedPermissionSets.length; i++)
      String[] requiredPermissions = allowedPermissionSets[i].split(",");
      if (log.isDebugEnabled()) log.debug("requiredPermissions=" + Arrays.asList(requiredPermissions));
      boolean gotAllInList = true;
      for (int j = 0; j < requiredPermissions.length; j++)
      if (!SecurityService.unlock(requiredPermissions[j].trim(), site.getReference()))

      { gotAllInList = false; break; }

      if (gotAllInList)

      { return true; }


      // No permission sets were matched.
      return false;

        Gliffy Diagrams



              Issue Links



                  • Assignee:
                    steve.swinsburg Steve Swinsburg
                    steve.swinsburg Steve Swinsburg
                  • Votes:
                    0 Vote for this issue
                    2 Start watching this issue


                    • Created:

                      Git Integration