cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend the user model?

lista
Star Contributor
Star Contributor
I'd like someone who already dealt with this to give me an advice.
How would you extend the user model, or to put it in another words, how would you add your own custom properties to the user?
Obviously, the original contentModel.xml should not be modified.

All advices are welcome.

Cheers,
Lista.
23 REPLIES 23

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
true, you can create aspect and add it to person on adding it .
but if you really need to change model, just change it but pay  attention  latter when you ugrade alfresco .

richard_im
Champ in-the-making
Champ in-the-making
This has been done in the past, but as the previous poster notes, you would need to add it to the contentModel.xml or using aspects.

Whichever route you take, you would need to modify the various user specific pages in /alfresco and /share.  For /share, you would also need to add addtional java classes for the userbean.

But, this is also dependent on how you are going to use this additional model data.

lista
Star Contributor
Star Contributor
Thank you both for your answers.

I think I'll be using a combination of aspects and associations.
In addition to all the properties I need, aspect will also hold an association to the 'original user'. These two will form a 'new user', with all the necessary properties.

This way, I don't need to touch the original model. And since I'm using Alfresco as a repository, richard.im's remarks about specific pages are not of importance.

Cheers,
Lista.

lucille_arkenst
Champ in-the-making
Champ in-the-making
Right.  Also, I think the conventional way is to put your customisations in the "extensions" folder.  (There are two extensions folders; find the one in sub-directory under Tomcat.) http://wiki.alfresco.com/wiki/Step-By-Step:_Creating_A_Custom_Model  See #3: "Making the new content model file available to the Alfresco container as an extension."  This way you don't have to worry about conflicts with the original model, and you don't have to worry when upgrading Alfresco.

Cheers

inocka
Champ in-the-making
Champ in-the-making
Hi, may be you could tell me how to add aspect to alfresco user (3.3 version)?
It will be two different aspects and I should be able to limit user search using them. Any ideas how to do that?
I will really appreciate any help, because I am really limited in time resources.
Thanks

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
can you send me specs on aspects and I will provide you with needed modifications.

inocka
Champ in-the-making
Champ in-the-making
It will be something like:     
<aspects>
       <aspect name="as:IsClubMember">
         <title>Club member info</title>
         <properties>
            <property name="as:memberCode">
               <type>d:text</type>
            </property>
            <property name="as:validTill">
               <type>d:text</type>
            </property>
         </properties>
      </aspect>
      <aspect name="as:HasAccsess">
         <title>Access to sistem</title>
         <properties>
            <property name="as:Enabled">
               <type>d:text</type>
            </property>
         </properties>
      </aspect>
   </aspects>

All users, if they want to provide their club member info, should have possibility to add as:IsClubMember aspect.
Admin user should have possibility to set as:HasAccsess to the user.

Hope it helps you to answer my question ASAP.

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
ok so
All users, if they want to provide their club member info, should have possibility to add as:IsClubMember aspect.
This is first problem because user can not add aspect on him self, so you have to use runAs part for this.
javadoc on runas you have hire
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=alfresco+runas
click on third result .


Admin user should have possibility to set as:HasAccsess to the user.
this is not a problem. just add action in userlist":\jsp\users\users.jsp

and last how to add aspect on a user example.
 Map<QName,Serializable> auditableProps = 
        new HashMap<QName,Serializable>();
      auditableProps.put(ContentModel.PROP_CREATOR, blog.getCreator());
      auditableProps.put(ContentModel.PROP_CREATED, blog.getCreated());
      auditableProps.put(ContentModel.PROP_MODIFIER, blog.getModifier());
      auditableProps.put(ContentModel.PROP_MODIFIED, blog.getModified());
      nodeService.addAspect(
        profileRef, ContentModel.ASPECT_AUDITABLE, auditableProps);

hope it helps!

inocka
Champ in-the-making
Champ in-the-making
Thanks for quick answer. I'll write if I'll have problems.