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

View: New views
2 Messages — Rating Filter:   Alert me  

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

by Valerie Nyre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

Re: How to access the results of User.getAllRoles() from JavaScript

by karel_vervaeke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy