[daisy] How to access the results of User.getAllRoles() from JavaScript

Karel Vervaeke karel at outerthought.org
Wed Jun 25 18:02:33 CEST 2008


This should print out all the roles assigned to a user:

var roles = user.allRoles.array;
for (var i=0; i<roles.length; i++) {
  println (roles[i].name + "--" + roles[i].description);
}

There is little point to add one of these roles to the user because he
already has all of them:

user.addToRole(roles[0]); // <-- pointless 

However:

anotherUser = userManager.getUser(5, true);
anotherUser.addToRole(roles[0]); // <-- might be useful

To get a complete list of all the roles you need:

userManager.roles;  (which returns something with the same type as
user.allRoles)

The Daisy API is hosted here:
http://cocoondev.org/javadoc/daisy/2.2
(You might want to use it to figure out what user.allRoles is returning
and what you can do with it)

I hope this answers your questions,
Karel

On Wed, 2008-06-25 at 17:15 +0200, Valerie Nyre wrote:
> Hello
> 
> I am not too adept at JavaScript.
> 
> What is the preferred method to access and use the results of the User 
> getAllRoles() method.
> 
> I would like to
> get the name and description of the role
> select a role to be passed as parameter in another addToRole()-statement
> 
> 
> Thank you
> 
> 
> Valerie Nyre
> 
> Maas High Tech Software
> 
> 
> _______________________________________________
> daisy community mailing list
> Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy


More information about the daisy mailing list