Farcry Custom Permission Sets
I don’t really recall at this point how I got started messing around with this but I think it’s pretty neat.
I was wondering how to create custom permissions for custom types. For example, when I do a custom type, I have traditionally applied the news permissions to it so anyone who has permissions to add/edit news items would be able to add/edit my custom type. But, what if you want specific permissions for your type? Here’s how you do it (in Farcry 3 that is)…
First of all, I am going to assume you have a custom type set up and have extended the webtop. Second, I’m going to assume that you have a link in the webtop that opens some type of typeadmin for your type. Here’s an example:
<cfimport taglib="/farcry/farcry_core/tags/admin/" prefix="admin">
<cfimport taglib="/farcry/farcry_core/tags/widgets/" prefix="widgets">
<cfset editobjectURL = "#application.url.farcry#/conjuror/invocation.cfm?objectid=##recordset.objectID[recordset.currentrow]##&typename=dmimage">
<!--- set up page header --->
<admin:header title="Snippet Administration" writingDir="#session.writingDir#" userLanguage="#session.userLanguage#" onload="setupPanes('container1');">
<widgets:typeadmin
typename="jcSnippet"
permissionset="snippet"
title="Snippet Administration"
bdebug="0">
</widgets:typeadmin>
<admin:footer>
Notice that my call to typeadmin includes the typename and a permissionset. I usually used “news” there but I have created a new one called “snippet.”
Now, in Farcry, click on the Security tab, change the dropdown to Policy and click on the Permissions link on the left. Click on “Add Permission.” This allows you to create a new permission which contians a Name, Notes, and Type. Notes is optional and Type should be “PolicyGroup” because this is the standard group actually hard-coded into the typeadmin file for checking permissions on a custom type.
Now, a word on names…Check out all the permissions listed when you first click on Permissions. We’ll take Event as an example. We have the following permissions:
- EventApprove
- EventCanApproveOwnContent
- EventCreate
- EventDelete
- EventEdit
- EventRequestApproval
Notice all of the possible actions are prepended with the word event. Now, go back up and look at the code that I provided. The permission set I am sending typeadmin is “snippet”, therefore it is looking for any permissions with “snippet” prepended. By default, I usually use “news” so it uses all of the news permissions.
So, to create custom permissions, just add new permissions with your permissionset name prepended to one of the 6 available actions. If you want someone to be able to edit and request approval on items but not create new ones or delete them, you would create two permissions like this: snippetEdit and snippetRequestApproval.
Of course, you need to assign these permissions to a policy group. That’s really the point of all this. You can create a new policy group that has access only to your type (call it snippetGroup). When you click “Policy Group Permissions” you will now see the new permissions you created that you can set to yes/no for each Policy Group. (By the way, that’s why in “Permission Type” when adding a permission you put “PolicyGroup”. There are others in there but from what I’ve seen so far with this, they don’t play a part in the typeadmin.
This may have all changed in 4.0. I haven’t been able to use that release yet but from what I’ve heard, 4.1 is when they will be refactoring the permissions, so hopefully this concept remains the same for all versions of Farcry currently being used.