Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To restate, providing the user does not customize his or her layout, when the user's portal template attribute values changes, the portal will present the new layout and pull the user out of all past groups that it can (cannot modify read-only groups such as PAGS groups) and place this user into the new groups affiliated with the new template user, whereas in the event that a user modifies his or her layout and thereby breaks association with the template user, then even if the portal template attribute changes, the user will not receive a new layout nor will she change group membership.

Source code snippets implementing the described behavior

Code Block
java
java
titleOnly users without their own layouts are updated

 boolean hasSavedLayout = userHasSavedLayout(portalUser.getUserId());
 if (!hasSavedLayout) {
                       
     TemplateUser templateUser = getTemplateUser(templateName);                       
     if (portalUser.getDefaultUserId() != templateUser.getUserId()) {
            //Update user data with new template user's data
            updateUser(portalUser.getUserId(), person, templateUser);
         }
     }
Code Block
java
java
titleChanging template affiliation changes group memberships

 protected void updateUser(int userId, IPerson person, TemplateUser templateUser) throws Exception {
      // Remove my existing group memberships
      IGroupMember me = GroupService.getGroupMember(person.getEntityIdentifier()); 
      Iterator myExistingGroups = me.getContainingGroups();
      while (myExistingGroups.hasNext()) {
          IEntityGroup eg = (IEntityGroup)myExistingGroups.next();
          ILockableEntityGroup leg = GroupService.findLockableGroup(eg.getKey(), me.getKey());
          removePersonFromGroup(person, me, leg);
      }
      
      // Copy template user's groups memberships
      IGroupMember template = GroupService.getEntity(templateUser.getUserName(), Class.forName("org.jasig.portal.security.IPerson"));
      Iterator templateGroups = template.getContainingGroups();
      while (templateGroups.hasNext()) {
          IEntityGroup eg = (IEntityGroup)templateGroups.next();
          ILockableEntityGroup leg = GroupService.findLockableGroup(eg.getKey(), me.getKey());
          addPersonToGroup(person, me, leg);     
      }