Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Panel
borderColor#ccc
bgColor#FFFFCE
titleBGColor#F7D6C1
borderStyledashed
titleThe QuestionborderStyledashed

Vinny Khosla asked on the JASIG-PORTAL list:

How do i setup a user layout template?
Subsequently, how do I go about creating subsequent user accounts who would inherit the layout template?

Could you please tell me what tables, columns and xml files are involved
here?

Do the new users automatically inherit the layout template?
or Is there a way to force a new user to inherit a certain custom layout
template ?

...

Source code snippets implementing the described behavior

Code Block
java
java
titleOnly users without their own layouts are updatedjava
 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 membershipsjava
 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);     
      }