ayoub idelhoussain ayoub idelhoussain - 1 month ago 10
PHP Question

Creating user home folder from template folder

I have a model folder

"0000"
in a directory A in
alfresco
and whenever a new user is created , I have to create a folder for him with the same folder structure as the model folder , I found through rest api, that I can do that with this :

{"alf_destination": "workspace://SpacesStore/35818681-274f-4d61-8fe7-5cff238513e5",
"prop_cm_name": "0000",
"prop_cm_title": "",
"prop_cm_description": "",
"sourceNodeRef": "workspace://SpacesStore/aeeaca0a-89bf-4294-8506-315ecd7d18f2",
"parentNodeRef": "workspace://SpacesStore/35818681-274f-4d61-8fe7-5cff238513e5"
}


but how can I get the that spacestore
/{id}
in php ?

and I have created the dest folder via
ftp_mkdir
because I didn't understand how to do it with alfresco (I didn't know what a {container} and site's name is )
here is the path to the model :
/Alfresco/Dictionnaire de données/Modèles d'espace/0000


and here where the new folders will be created :
/Alfresco/Data/users

pardon my english and Thank you

Answer

There is the userHomesHomeFolderProvider that allows you inject Home Folder Template. You can find its definition inside this library: tomcat/webapps/alfresco/WEB-INF/lib/alfresco-repository-{ver}.jar/alfresco/authentication-services-context.xml:

<bean name="userHomesHomeFolderProvider" parent="usernameHomeFolderProvider">
    <property name="rootPath">       
       <value>/${spaces.company_home.childname}/${spaces.user_homes.childname}</value>
    </property>
    <property name="storeUrl">
        <value>${spaces.store}</value>
    </property>
</bean>

You can customize this bean as follows:

  1. Create the template folder and its content (files, sub-folders,..), for example: Repository> Data Dictionary> user_homes_templates> custom_home_root

  2. Override the userHomesHomeFolderProvider bean definition and inject the new property templatePath pointing to the template folder. Create the file tomcat/shared/classes/alfresco/extension/user-homes-custom-context.xml with the new bean definition:

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
    <beans>
        <bean name="userHomesHomeFolderProvider" parent="usernameHomeFolderProvider">
            <property name="rootPath">
                <value>/${spaces.company_home.childname}/${spaces.user_homes.childname}</value>
            </property>
            <property name="storeUrl">
                <value>${spaces.store}</value>
            </property>
            <property name="templatePath">
                <value>/app:company_home/app:dictionary/cm:user_homes_templates/cm:custom_home_root</value>
            </property>
        </bean>
    </beans>
    

Now restart Alfresco and create the new user, template content will be copied into the new user home folder (Repository> User Homes> {user-name}).

... and if you really must use PHP try Apache Chemistry CMIS PHP Client or REST API.

Comments