Copied to clipboard

Flag this post as spam?

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


  • Luke 110 posts 256 karma points
    Jun 26, 2015 @ 14:08
    Luke
    0

    Back-office Search Facility

    Hi All,

    I need to prevent certain members appearing when a user is using the search facility in the back office. Does anyone know how you can filter the results or add an event to the search operation?

    Regards, L

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jun 26, 2015 @ 19:26
    Marcel van Helmont
    0

    Hello Luke,

    If i have it correct then the search in de backoffice use Examine. So what you can do is hookup to the

    ExamineManager.Instance.IndexProviderCollection["InternalMemberIndexer"].GatheringNodeData

    and then remove the usernames that you don't want to be index.

    Marcel

  • Luke 110 posts 256 karma points
    Jun 27, 2015 @ 06:52
    Luke
    0

    Thank you kindly Marcel,

    Great info - do you know where I would hook into this?? Maybe Application Startup.

    Regards, L

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jun 27, 2015 @ 08:14
    Marcel van Helmont
    0

    Hi Luke,

    Yes but many this topic is more helpful and a beter solution.

    https://our.umbraco.org/forum/core/general/30555-Programmatically-remove-an-item-from-Examine-Index-on-unpublish?p=0

    it's for content but you can change it for members also, something like this:

    public class UmbracoApplicationEventListener : ApplicationEventHandler
    {
        protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
        MemberService.Saved += MemberService_Saved;
        }
    
        void MemberService_Saved(IMemberService sender, global::Umbraco.Core.Events.SaveEventArgs<IMember> e)
        {
            var examineManager = ExamineManager.Instance.IndexProviderCollection["InternalMemberIndexer"];
    
            foreach (var member in e.SavedEntities)
            {
                if (member.Name == "membernametodelete")
                {
                    examineManager.DeleteFromIndex(member.Id.ToString());
                }
            }
        }
    }
    
  • Luke 110 posts 256 karma points
    Jun 29, 2015 @ 06:22
    Luke
    0

    Hi Marcel,

    Thank you for this - but I am not sure it would work as it needs to be dynamic for the user. For instance User type exampleType1 is allowed to view certain members and User Type exampleType2 is allowed to view others.

    I filtered out the members section with:

    Umbraco.Web.Trees.TreeControllerBase.TreeNodesRendering += TreeControllerBase_RootNodeRendering;
    

    But needs something similar with the search facility.

    Regards, L

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jun 29, 2015 @ 07:09
    Marcel van Helmont
    0

    Hi Luke,

    I don't know a way to to filtering based on the user type in search. There is no event to hookup in the search result pipeline.

    The only way i can think about it to do it with some kind of interceptor.

    our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/53699-User-Message-former-Speech-bubble-in-custom-event#comment-197032

    or by angular

    https://github.com/kgiszewski/LearnUmbraco7/blob/master/Chapter%2011%20-%20Working%20with%20AngularJs%20for%20Customizing%20the%20Backoffice/06%20-%20Interceptors.md

    But this are tricky and hacks not a really need solution.

    Good luck

  • Luke 110 posts 256 karma points
    Jun 29, 2015 @ 18:43
    Luke
    0

    Hi,

    Thanks - just wondering though if I can hook into an event that checks the url. For example I can check that the url contains member/edit/ then I can see if the current user has access to that member if not then redirect them to unauthorized.

    Do you know (or anybody) know how I could do this?

    Regards, L

Please Sign in or register to post replies

Write your reply to:

Draft