[xwiki-devs] [Gsoc - 2009] XWIKI-3337 Jira Issue
Hi, I am interested in solving this Jira issue and I have been working on it. Its about displaying a warning to user when creating a user with a user name that already exists. Issue occurs when adding users from admin account. Below are the given steps to generate it Administration -> 'Users' -> Add New User -> Try creating user with same user name -> Nothing happens (or warning) Adding a user from register button displays warning and uses warnings defined in registerinline.vm called from register.vm template. I have started looking at the xwiki-core code, specifically com.xpn.xwiki.web. What I found is as follows when adding a user with same user name, when creating a new user from RegisterAction class -> xwiki.createUser(true,"edit",context) returns -3 indicating user already exists. And when adding from Administration panel I found it calls a template 'registeruser?ajax=1.vm' that is not in /templates folder. There fore, can you suggest me some steps to display a warning to user, when adding users from Administration panel. It uses Ajax to display 'add new user' UI. Here I am not clear on what template is being called and what to look for the next step. I have just stuck with this. I thought of sending a mail, I would get some points to continue with. Thank you, *H.T.M. Gamage ** *Student,* * Faculty of Information Technology, University of Moratuwa, SriLanka. Mobile: +94 (71) 5518852 Blog : tharindufit.wordpress.com
Hi, By having a quick look I noticed that when you go to the Administration panel to add a new user the following happens: * admin.vm template is loaded (notice the admin action in the URL) * admin.vm includes XWiki.AdminSheet * XWiki.AdminSheet includes XWiki.AdminUsersSheet (notice section=Users in the URL) * in XWiki.AdminUsersSheet a click listener is registered to the addNewUser button * when the addNewUser button is clicked the registeruser.vm template is rendered in a light box Hope this helps, Marius Tharindu Madushanka wrote:
Hi, I am interested in solving this Jira issue and I have been working on it. Its about displaying a warning to user when creating a user with a user name that already exists. Issue occurs when adding users from admin account. Below are the given steps to generate it
Administration -> 'Users' -> Add New User -> Try creating user with same user name -> Nothing happens (or warning)
Adding a user from register button displays warning and uses warnings defined in registerinline.vm called from register.vm template. I have started looking at the xwiki-core code, specifically com.xpn.xwiki.web. What I found is as follows when adding a user with same user name, when creating a new user from RegisterAction class -> xwiki.createUser(true,"edit",context) returns -3 indicating user already exists. And when adding from Administration panel I found it calls a template 'registeruser?ajax=1.vm' that is not in /templates folder. There fore, can you suggest me some steps to display a warning to user, when adding users from Administration panel. It uses Ajax to display 'add new user' UI. Here I am not clear on what template is being called and what to look for the next step. I have just stuck with this. I thought of sending a mail, I would get some points to continue with.
Thank you,
*H.T.M. Gamage ** *Student,* * Faculty of Information Technology, University of Moratuwa, SriLanka. Mobile: +94 (71) 5518852 Blog : tharindufit.wordpress.com _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Tharindu Madushanka wrote:
Hi, I am interested in solving this Jira issue and I have been working on it. Its about displaying a warning to user when creating a user with a user name that already exists. Issue occurs when adding users from admin account. Below are the given steps to generate it
Administration -> 'Users' -> Add New User -> Try creating user with same user name -> Nothing happens (or warning)
Adding a user from register button displays warning and uses warnings defined in registerinline.vm called from register.vm template. I have started looking at the xwiki-core code, specifically com.xpn.xwiki.web. What I found is as follows when adding a user with same user name, when creating a new user from RegisterAction class -> xwiki.createUser(true,"edit",context) returns -3 indicating user already exists. And when adding from Administration panel I found it calls a template 'registeruser?ajax=1.vm' that is not in /templates folder. There fore, can you suggest me some steps to display a warning to user, when adding users from Administration panel. It uses Ajax to display 'add new user' UI. Here I am not clear on what template is being called and what to look for the next step. I have just stuck with this. I thought of sending a mail, I would get some points to continue with.
Of course there is a registeruser template in the /templates folder. It's called registeruser.vm. When a URL contains xpage=xyz, then the xyz.vm template is the one producing the output. A good tool you can use is the Firebug Firefox plugin, which allows to monitor ajax requests. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi, I noticed that when we click save button from with in the lightbox, following code gets executed when it calls Util.parseTemplate() the parameter for template parsed here is registeruser?ajax=1 if (content.equals("")) { // get Error template "This template does not exist content = context.getWiki().parseTemplate("templatedoesnotexist.vm", context); content = content.trim(); } There fore, registeruser.vm is never called from lightbox when click 'Save' as I noticed. I am not sure on the usage of ?ajax=1 infront of template name. Can I get some explain on it.
I think this ?ajax=1 part is appended from lightbox's lbSaveSync: function(url), called from lbSaveForm: function() lbSaveSync: function(url) { new Ajax.Request(url + "?ajax=1", {parameters: this.formData, asynchronous: false}); } But the usage of it is not clear for me. I mean '?ajax=1' part, I think after that Utils.parseTemplate() use "registeruser?ajax=1" as template parameter, not calling the template to display the warnings appropriately defined in "registeruser" template.
Tharindu Madushanka wrote:
I think this ?ajax=1 part is appended from lightbox's lbSaveSync: function(url), called from lbSaveForm: function()
lbSaveSync: function(url) { new Ajax.Request(url + "?ajax=1", {parameters: this.formData, asynchronous: false}); }
But the usage of it is not clear for me. I mean '?ajax=1' part, I think after that Utils.parseTemplate() use "registeruser?ajax=1" as template parameter, not calling the template to display the warnings appropriately defined in "registeruser" template.
This looks like a bug. Please open an issue on Jira for it. -- Sergiu Dumitriu http://purl.org/net/sergiu/
I have changed "?ajax=1" in lightbox.js in two places to "&ajax=1" lbSave: function(url) { this.lbSaveData(); new Ajax.Request(url + "&ajax=1", {parameters: this.formData, onSuccess: this.lbSaveDone.bind(this)}); }, lbSaveSync: function(url) { new Ajax.Request(url + "&ajax=1", {parameters: this.formData, asynchronous: false}); }, After this correct template is selected but it does not stop to display the warning with in lightbox. The parsed template has the warning message in it. But view does not stop to display the warnings.
participants (3)
-
Marius Dumitru Florea -
Sergiu Dumitriu -
Tharindu Madushanka