[xwiki-devs] How to add a user to a group!
Hello Devs, In our project we need to eb able to assign different rights to different users but, we do not want to give access to the Administration Page to everybody. So, I create a page where I would fill in a drop down box wit user names and group name and then write a script to add the selected user tothe selected group. For this, I did the following but, this added objects of XWiki.XWikiGroup(one for each of the users) to this page and now this page shows up in my Admin space with the other groups. Is there a method to just get a list of all user names in the XWiki, that I can use instead of using this complex query. or Is there a better way to do this. Also, once I select a user and a group, how do I add the user to the group. Is there a method/script for that? I see a "adduorg.vm" in the templates. What is the purpose of this script? where is it called? What is "uorg"? Use this Form to Assign New Roles or modify Existing Roles for the members of ROCK! <html> <form> Select User: <select name="currentusers"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #foreach ($item in $xwiki.searchDocuments($sql)) #set($userdoc=$xwiki.getDocument($item)) #set($userobj=$userdoc.getObject("XWiki.XWikiUsers")) #set($username=$userobj.getName()) <option value="$username">$username</option> #end </select> Select Role: <select name="rockroles"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups' and obj.name<>'XWiki.XWikiGroupTemplate'") #foreach ($item in $xwiki.searchDocuments($sql)) <option value="$item">$item</option> #end </select> </form> </html> Please help! Thanks
On Thu, Apr 24, 2008 at 7:16 PM, Kamna Jain <[email protected]> wrote:
Hello Devs,
In our project we need to eb able to assign different rights to different users but, we do not want to give access to the Administration Page to everybody. So, I create a page where I would fill in a drop down box wit user names and group name and then write a script to add the selected user tothe selected group.
For this, I did the following but, this added objects of XWiki.XWikiGroup(one for each of the users) to this page and now this page shows up in my Admin space with the other groups. Is there a method to just get a list of all user names in the XWiki, that I can use instead of using this complex query. or Is there a better way to do this.
Look at rightsmanager plugin api : http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/index.html It contains lots of methods to retrieve users and group with filters, limit, sort...
Also, once I select a user and a group, how do I add the user to the group. Is there a method/script for that? I see a "adduorg.vm" in the templates. What is the purpose of this script? where is it called? What is "uorg"?
There is not api to add user in groups. I think "uorg" means "user or group" and is used by ajax based users/groups admin interface. You can look at this file for a example of how to add a user in a group or maybe even use it directly.
Use this Form to Assign New Roles or modify Existing Roles for the members of ROCK!
<html> <form> Select User: <select name="currentusers"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #foreach ($item in $xwiki.searchDocuments($sql)) #set($userdoc=$xwiki.getDocument($item)) #set($userobj=$userdoc.getObject("XWiki.XWikiUsers")) #set($username=$userobj.getName()) <option value="$username">$username</option> #end </select>
Select Role: <select name="rockroles"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups' and obj.name<>'XWiki.XWikiGroupTemplate'") #foreach ($item in $xwiki.searchDocuments($sql)) <option value="$item">$item</option> #end
</select> </form> </html>
Please help!
Thanks _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Thanks Thomas, for your reply. I was looking at the API and it has lots of methods we could use. But, I am not able to use them ..:( #set($rightsAPI=$xwiki.get("RightsManagerPluginApi")) #set($num=$rightsAPI.countAllMembersNamesForGroup("XWiki.ROCKPMGroup")) or #set($cxt=$rightsAPI.getXWikiContext()) #set($num=$cxt.countAllMembersNamesForGroup("XWiki.ROCKPMGroup")) or #set($num=$xwiki.countAllMembersNamesForGroup("XWiki.ROCKPMGroup")) number $num I tried the above and it does not work. Can you please tell me what is wrong in the way I am tyring to use the API Thanks a lot On 4/24/08, Kamna Jain <[email protected]> wrote:
Hello Devs,
In our project we need to eb able to assign different rights to different users but, we do not want to give access to the Administration Page to everybody. So, I create a page where I would fill in a drop down box wit user names and group name and then write a script to add the selected user tothe selected group.
For this, I did the following but, this added objects of XWiki.XWikiGroup(one for each of the users) to this page and now this page shows up in my Admin space with the other groups. Is there a method to just get a list of all user names in the XWiki, that I can use instead of using this complex query. or Is there a better way to do this.
Also, once I select a user and a group, how do I add the user to the group. Is there a method/script for that? I see a "adduorg.vm" in the templates. What is the purpose of this script? where is it called? What is "uorg"?
Use this Form to Assign New Roles or modify Existing Roles for the members of ROCK!
<html> <form> Select User: <select name="currentusers"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #foreach ($item in $xwiki.searchDocuments($sql)) #set($userdoc=$xwiki.getDocument($item)) #set($userobj=$userdoc.getObject("XWiki.XWikiUsers")) #set($username=$userobj.getName()) <option value="$username">$username</option> #end </select>
Select Role: <select name="rockroles"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups' and obj.name <>'XWiki.XWikiGroupTemplate'") #foreach ($item in $xwiki.searchDocuments($sql)) <option value="$item">$item</option> #end
</select> </form> </html>
Please help!
Thanks
On Fri, Apr 25, 2008 at 4:50 PM, Kamna Jain <[email protected]> wrote:
Thanks Thomas, for your reply. I was looking at the API and it has lots of methods we could use. But, I am not able to use them ..:(
#set($rightsAPI=$xwiki.get("RightsManagerPluginApi"))
To acces a plugin api o have to use $xwiki.<pluginname>. See http://platform.xwiki.org/xwiki/bin/view/DevGuide/CreatingPlugins. For rightsmanager plugin : $xwiki.rightsmanager will return you a RightsManagerPluginApi object
#set($num=$rightsAPI.countAllMembersNamesForGroup("XWiki.ROCKPMGroup")) or #set($cxt=$rightsAPI.getXWikiContext()) #set($num=$cxt.countAllMembersNamesForGroup("XWiki.ROCKPMGroup")) or #set($num=$xwiki.countAllMembersNamesForGroup("XWiki.ROCKPMGroup")) number $num
I tried the above and it does not work. Can you please tell me what is wrong in the way I am tyring to use the API
Thanks a lot
On 4/24/08, Kamna Jain <[email protected]> wrote:
Hello Devs,
In our project we need to eb able to assign different rights to different users but, we do not want to give access to the Administration Page to everybody. So, I create a page where I would fill in a drop down box wit user names and group name and then write a script to add the selected user tothe selected group.
For this, I did the following but, this added objects of XWiki.XWikiGroup(one for each of the users) to this page and now this page shows up in my Admin space with the other groups. Is there a method to just get a list of all user names in the XWiki, that I can use instead of using this complex query. or Is there a better way to do this.
Also, once I select a user and a group, how do I add the user to the group. Is there a method/script for that? I see a "adduorg.vm" in the templates. What is the purpose of this script? where is it called? What is "uorg"?
Use this Form to Assign New Roles or modify Existing Roles for the members of ROCK!
<html> <form> Select User: <select name="currentusers"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #foreach ($item in $xwiki.searchDocuments($sql)) #set($userdoc=$xwiki.getDocument($item)) #set($userobj=$userdoc.getObject("XWiki.XWikiUsers")) #set($username=$userobj.getName()) <option value="$username">$username</option> #end </select>
Select Role: <select name="rockroles"> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups' and obj.name <>'XWiki.XWikiGroupTemplate'") #foreach ($item in $xwiki.searchDocuments($sql)) <option value="$item">$item</option> #end
</select> </form> </html>
Please help!
Thanks
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
participants (2)
-
Kamna Jain -
Thomas Mortagne