I have a situation whereby many users have access to create forms in Contour. However, due to the Contour security only the creator can see the forms unless an admin user checks the relevant box to allow access.
Is there anyway where I can automate this step or just have all Contour forms available to all users?
I've got it working. Thanks for your help in pointing me in the right direction.
Just posting this code should it help anybody else.
I created the following class in the App_Code folder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Forms;
using Umbraco.Forms.Data.Storage;
using umbraco.BusinessLogic;
using Umbraco.Forms.Core;
using umbraco.BusinessLogic;
///
/// Class for custom Contour Events
///
public class ContourEvents : ApplicationBase
{
public ContourEvents()
{
FormStorage.FormCreated += new EventHandler(FormStorage_FormCreated);
}
void FormStorage_FormCreated(object sender, FormEventArgs e)
{
AllowAccessForAllUsers(e);
}
void AllowAccessForAllUsers(FormEventArgs form)
{
var userFormSecurityStorage = new UserFormSecurityStorage();
// loop through all users and allow access
User[] users = User.getAll();
foreach (User user in users)
{
UserFormSecurity userFormSecurity = new UserFormSecurity();
userFormSecurity.User = user.Id; // this needs to be Id, not just user
userFormSecurity.HasAccess = true;
userFormSecurity.Form = form.Form.Id;
userFormSecurity.SecurityType = global::Umbraco.Forms.Core.Enums.FormSecurityType.Full;
userFormSecurityStorage.InsertUserFormSecurity(userFormSecurity);
}
}
}
Hi guys,
Dont know if this issue is still open or not, but I'm getting an intellisense error message when I create the class in the appcode folder and copy paste this code. The error says "No overload for FromStorageFormCreated matches delegate 'eventHandler'". I'm assuming that i'm missing something.
Help would be nice.
Best regards
Contour Security
I have a situation whereby many users have access to create forms in Contour. However, due to the Contour security only the creator can see the forms unless an admin user checks the relevant box to allow access.
Is there anyway where I can automate this step or just have all Contour forms available to all users?
Thanks
Comment author was deleted
Hi Ben,
Yup you can automate this, there is an event available on form create, will post some details tomorrow
Cheers,
Tim
Comment author was deleted
Umbraco.Forms.Data.Storage.FormStorage has an FormCreated event that you can use
You can then use the UserFormSecurityStorage part to set the security for the newly created form
Hi Tim,
I've got it working. Thanks for your help in pointing me in the right direction.
Just posting this code should it help anybody else.
I created the following class in the App_Code folder
Hi guys, Dont know if this issue is still open or not, but I'm getting an intellisense error message when I create the class in the appcode folder and copy paste this code. The error says "No overload for FromStorageFormCreated matches delegate 'eventHandler'". I'm assuming that i'm missing something. Help would be nice. Best regards
is working on a reply...