Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ben McKean 272 posts 549 karma points
    Mar 20, 2013 @ 16:58
    Ben McKean
    0

    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

    Mar 20, 2013 @ 21:32

    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

    Mar 21, 2013 @ 11:24

    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

  • Ben McKean 272 posts 549 karma points
    Mar 21, 2013 @ 16:30
    Ben McKean
    1

    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 

    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);
            }
        }
    }
    
  • Rui Vaz 1 post 71 karma points
    Oct 28, 2016 @ 08:20
    Rui Vaz
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft