Re: [xwiki-users] API/Scripting : create user and attach some files to its profile

2016-12-09 Thread Eduard Moraru
Hi,

Did not follow the discussion in depth, but maybe you are interested in
adding an EventListener on either DocumentCreatingEvent [1] (before) or
DocumentCreatedEvent [2] (after).

Other, more specialized, events exist as well, such as
XObjectAdded/Updated/DeletedEvent [7][8][9] that allows you to catch a user
profile page that was just created (example usage [6]). This way you`re
avoiding to do extra work in checking the type of the created page, like
you would have to do with DocumentCreatedEvent.

The event listener [3] can be built and added either as a java component
[4], a wiki component [5] or with a custom groovy script that does things
manually.

Hope this helps,
Eduard

--
[1]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
[2]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
[3]
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutorial
[4] http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents
[5]
http://extensions.xwiki.org/xwiki/bin/view/Extension/WikiComponent+Module
[6]
https://github.com/xwiki/xwiki-platform/blob/456d6149d12d36f5481e70759e7974815591a2c1/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/event/CommentEventGeneratorListener.java#L63
[7]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/event/XObjectAddedEvent.java
[8]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/event/XObjectUpdatedEvent.java
[9]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/event/XObjectDeletedEvent.java

On Thu, Dec 8, 2016 at 2:41 PM, Hamster  wrote:

> 1) I am not cutting any post. I use Nabble.
>
> http://xwiki.475771.n2.nabble.com/Re-API-Scripting-create-
> user-and-attach-some-files-to-its-profile-td7601934.html
>
> 2) I think my example shows perfectly what you want to accomplish. You want
> to attach an PDF to something which does not yet exist.
>
> Don't be scorned, I am just putting things in perspective. Unless there's
> an
> API which allows you to attach items to pages during the creation of the
> page. Otherwise the procedure will have to be (1) check if a user profile
> exists, if "yes" then attach file, if "no" then first create the user
> profile and then attach the file.
>
>
>
> --
> View this message in context: http://xwiki.475771.n2.nabble.
> com/Re-API-Scripting-create-user-and-attach-some-files-to-
> its-profile-tp7601934p7602032.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
>


Re: [xwiki-users] API/Scripting : create user and attach some files to its profile

2016-12-08 Thread Hamster
1) I am not cutting any post. I use Nabble.

http://xwiki.475771.n2.nabble.com/Re-API-Scripting-create-user-and-attach-some-files-to-its-profile-td7601934.html

2) I think my example shows perfectly what you want to accomplish. You want
to attach an PDF to something which does not yet exist.

Don't be scorned, I am just putting things in perspective. Unless there's an
API which allows you to attach items to pages during the creation of the
page. Otherwise the procedure will have to be (1) check if a user profile
exists, if "yes" then attach file, if "no" then first create the user
profile and then attach the file.



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Re-API-Scripting-create-user-and-attach-some-files-to-its-profile-tp7601934p7602032.html
Sent from the XWiki- Users mailing list archive at Nabble.com.


Re: [xwiki-users] API/Scripting : create user and attach some files to its profile

2016-12-08 Thread m...@ow2.org
Le 08/12/2016 à 10:42, Hamster a écrit :
> That sounds a lot like...
> 
> "Here's a file, you should save it in that non-existing folder"
> 
> "But the folder does not exist yet...how am I going to save that file???"

When you are turning my request into a non-sense like this, I feel a
little scorned. Still this is a real question with a real usecase
scenario. Would you have something valuable to bring ?

And you cut the remaining part of my post.

Cheers



Re: [xwiki-users] API/Scripting : create user and attach some files to its profile

2016-12-08 Thread Hamster
That sounds a lot like...

"Here's a file, you should save it in that non-existing folder"

"But the folder does not exist yet...how am I going to save that file???"




--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Re-API-Scripting-create-user-and-attach-some-files-to-its-profile-tp7601934p7602030.html
Sent from the XWiki- Users mailing list archive at Nabble.com.


Re: [xwiki-users] API/Scripting : create user and attach some files to its profile

2016-11-29 Thread m...@ow2.org
Hi Pascal,
Thanks for the tip :)

It answers to the "how to add a field" part of my question. But it
doesn't answer about attaching file to the profile. The main issue I see
here is the account is created on login. Or maybe there might be a hook
system so we can trigger something when the account is created( ie, to
attach files to the profile) ?

Cheers,

Le 28/11/2016 à 08:46, Pascal BASTIEN a écrit :
> Hello,
> 
> I added some others attributes (I don't know if you can do the same with file)
> Add some attributes here: /bin/edit/XWiki/XWikiUsers?editor=class
> e.g. myaddress
> (disabled it to prevent your user modified it)
> 
> Add this field "myaddress" on the sheet:  
> /bin/view/XWiki/AdminUserProfileSheet
> and finally add it in xwiki.cfg:
> #-# retrieve the following fields from LDAP and store them in the XWiki user 
> object (xwiki-attribute=ldap-attribute)
> xwiki.authentication.ldap.fields_mapping=last_name=sn,first_name=givenName,email=xcut,myaddress=street
> and choose a value for this setting:
> #-# On every login update the mapped attributes from LDAP to XWiki otherwise 
> this happens only once when the XWiki
> #-# account is created.
> #-# - 0: only when creating user
> #-# - 1: at each authentication
> #-# The default is 0
> xwiki.authentication.ldap.update_user=1
> 
> 
> (eventually add a XWiki.TranslationDocumentClass to translate myaddress 
> attribute)
> 
> 
> Pascal BASTIEN
> 
> ------------
> En date de : Ven 25.11.16, m...@ow2.org <m...@ow2.org> a écrit :
> 
>  Objet: [xwiki-users] API/Scripting : create user and attach some files to
> its profile
>  À: "XWiki Users" <users@xwiki.org>
>  Date: Vendredi 25 novembre 2016, 12h37
>  
>  Hi,
>  
>  I'm working on a registration system around xwiki.
>  
>  The basic workflow is the user is created in a LDAP
>  directory at
>  registration time. Then the user can login to xwiki.
>  It's only upon the first successful login to xwiki that the
>  user's xwiki
>  profile is created in xwiki database.
>  
>  Now here is my point : how could I prepare the user profile
>  *before* he
>  gets connected ? For example I would be able to attach some
>  files to
>  XWiki. and why not some others attributes.
>  
>  Is anyone already achieved this ?
>  
>  Cheers
>  ___
>  users mailing list
>  users@xwiki.org
>  http://lists.xwiki.org/mailman/listinfo/users
>  
> 



Re: [xwiki-users] API/Scripting : create user and attach some files to its profile

2016-11-27 Thread Pascal BASTIEN
Hello,

I added some others attributes (I don't know if you can do the same with file)
Add some attributes here: /bin/edit/XWiki/XWikiUsers?editor=class
e.g. myaddress
(disabled it to prevent your user modified it)

Add this field "myaddress" on the sheet:  /bin/view/XWiki/AdminUserProfileSheet
and finally add it in xwiki.cfg:
#-# retrieve the following fields from LDAP and store them in the XWiki user 
object (xwiki-attribute=ldap-attribute)
xwiki.authentication.ldap.fields_mapping=last_name=sn,first_name=givenName,email=xcut,myaddress=street
and choose a value for this setting:
#-# On every login update the mapped attributes from LDAP to XWiki otherwise 
this happens only once when the XWiki
#-# account is created.
#-# - 0: only when creating user
#-# - 1: at each authentication
#-# The default is 0
xwiki.authentication.ldap.update_user=1


(eventually add a XWiki.TranslationDocumentClass to translate myaddress 
attribute)


Pascal BASTIEN


En date de : Ven 25.11.16, m...@ow2.org <m...@ow2.org> a écrit :

 Objet: [xwiki-users] API/Scripting : create user and attach some files to  
its profile
 À: "XWiki Users" <users@xwiki.org>
 Date: Vendredi 25 novembre 2016, 12h37
 
 Hi,
 
 I'm working on a registration system around xwiki.
 
 The basic workflow is the user is created in a LDAP
 directory at
 registration time. Then the user can login to xwiki.
 It's only upon the first successful login to xwiki that the
 user's xwiki
 profile is created in xwiki database.
 
 Now here is my point : how could I prepare the user profile
 *before* he
 gets connected ? For example I would be able to attach some
 files to
 XWiki. and why not some others attributes.
 
 Is anyone already achieved this ?
 
 Cheers
 ___
 users mailing list
 users@xwiki.org
 http://lists.xwiki.org/mailman/listinfo/users
 
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] API/Scripting : create user and attach some files to its profile

2016-11-25 Thread m...@ow2.org
Hi,

I'm working on a registration system around xwiki.

The basic workflow is the user is created in a LDAP directory at
registration time. Then the user can login to xwiki.
It's only upon the first successful login to xwiki that the user's xwiki
profile is created in xwiki database.

Now here is my point : how could I prepare the user profile *before* he
gets connected ? For example I would be able to attach some files to
XWiki. and why not some others attributes.

Is anyone already achieved this ?

Cheers
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users