Add new filed to Orchard.Roles module - orchardcms

i need to extend the existing Orchard.Roles module adding a new field to store the Parent of a Role. I would do it from a my custom module, it's possible?
Thanks

Yes, the roles module has been designed to be replaceable. It has also been voluntarily designed to be very simple. If you need something more complex, with parent groups, you can take the existing module as a starting point, and build your own.

Related

Extending AccessInfo to Include Roles

I'm looking to extend the base Singleton "AccessInfo" to include additional information pertaining to the current user (such as roles.)
Is there a most favorable path to do this? I can see how to extend a Graph, Cache, but not seeing any documentation how to extend this area.
Unfortunately due to the way it has been implemented, there is not a way to add fields to that DAC and have them populated on instantiation, and since it's not selected from the DB like a normal DAC, I do not think events would fire for it.
If you would like to access Roles related to the current Users, this should suffice.
PXSelect<UsersInRoles,
Where<UsersInRoles.userName, Equal<Current<AccessInfo.userName>>>>.Select(this /*Or Base if it's a Graph Extension*/);
As there will likely be multiple Roles per user, you will need to loop.
foreach (UsersInRoles role in PXSelect<UsersInRoles, Where<UsersInRoles.userName, Equal<Current<AccessInfo.userName>>>>.Select(this /*Or Base if it's a Graph Extension*/))
{
//Some thing here
}

Associating existing Annotation to more than one entity

Say, organisation has an attachment document. Can I associate this attachment to parent organisation via plugin?
I know another annotation can be created for parent record and file attachment can be copied there. But I'd like to avoid storing copies of attached file.
In short, copying is your only option to have the annotation appear in both records.
The way Annotations are designed completely blocks this reasonable possibility. The Annotation "has-a" Object, even though in forms Objects are presented as the parent of Annotation. So we're stuck with the duplication.
You could always write your own microsoft-unsupported schema scripts and a web resource form control... Be sure to share with the community if you do :)

Per request variables in a node module? (express view helpers)

I am working on this project https://github.com/tanema/express-helpers that I forked fixed up and added new functionality to.
What I want to do it, instead of having to use form_tag_end() or even end_tag('tagname') I would just like to use a end() method. For this to work I need some sort of stack implementation for when a start tag is issued push onto the stack ect. I cannot just make a variable in the module called tagStack and just use that because it would create a race condition where the module is being used at the same time by two requests and the stack order gets messed up.
I was thinking if there was some way to have access to the request variable I would just store it in that and delete the variable if empty but I can't figure out how to do that.
Any suggestions?
Create your variable within a closure; it will be available within the scope of the instance, but not outside the instantiation of the functions, and will be garbage collected when the specific instances go out of scope.

Can required WCF4 DataMemeber's be organized into required groups?

Is there a way to have required DataMember's within a DataContract to be organized into groups so that you really only require group one or group two but no both to be provided?
I am looking to see if there is functionality similar to Workflow Activity validation where you can flag InArgument's with a RequiredArgument and then use OverloadGroup attribute to put these into groups so that only the arguments in one of the specified groups are required.
It is not possible out of the box with DataContractSerializer but you can switch to XmlSerializer and use xsd:choice (XmlChoiceIdentifierAttribute) but be aware that this will affect your data class beacuse this construct has its own requirements.
Nope, there is no way to do this. Only way to group is to have two different classes and extract away members/properties into those classes, but still...you won't be able to dictate an "either-on" setting.

Clean document roles in a Doc Library

I have been developing an event handler to clean up the RolesAssignments of the new item of a document library in MOSS. I’ve searched for a method that could clean all the RolesAssignments efficiently, although the best way I found seams to be loop through the RolesAssignments and delete one by one? Is there another way to clean all the RolesAssignments for an item?
The code I’m using for cleaning the RolesAssignments look like this:
for (int i = ListItem.RoleAssignments.Count - 1; i >= 0; --i)
{
ListItem.RoleAssignments.Remove(i);
}
Does anyone have any ideas on how to deal with this?
The example you've given within the body of your question is the most correct way to do this. ResetRoleInheritance and BreakRoleInheritance may do what you need, but this is the side-effect of the operations they perform. Their purpose is not to remove RoleAssignments, but rather operate on role inheritance. From MSDN:
ResetRoleInheritance - "Removes the local role assignments and reverts to role assignments from the parent object."
BreakRoleInheritance - "Creates unique role assignments for the item rather than inheriting them from a parent."
If role inheritance is already broken and you are using specific role assignments, you should remove them using a loop as you have in your question.
I have the answer, put the propertie SPListItem.BreakRoleInheritance(false) to break the role inheritance and remove the role assignments.
How about ResetRoleInheritance? This should clear out all of the RoleAssignments.

Resources