Search Users feature

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Search Users feature

Coleen_Astalos
We added a search users feature to my forum (which I REALLY like).  But I'm discovering a slight problem I'd like to see if we can figure out a way to change a bit.

Anyone can use the Search Feature.  All email addresses that have EVER been in the system will show in the Search.  I'd like to restrict it so that only those in the "Members" list are shown to non-administrative users.  But I still want Admins to be able to see the emails from all all users.

Is that possible?
-Coleen

Reply | Threaded
Open this post in threaded view
|

Re: Search Users feature

Pedro
For search only in members group you can add the filter like this:
<macro name="searched_users_list" dot_parameter="do" requires="node_page">   
    <n.site_users. start="0" length="99999">
        <n.filter_by.contains_substring string="[n.to_lower_case.current_user.name/]+[n.to_lower_case.current_user.user_email/]" substring="[n.to_lower_case.searchName/]"/>
        <n.filter_by.current_user.is_in_group group="Members"  />
        <n.do/>
    </n.site_users.>
</macro>
I will think in a way to make it only for non admins.
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Search Users feature

Coleen_Astalos
Could you add an IF check around this new filter to see if the iser is not an admin, then do the filter?

So something like:
IF user is not an admin
        <n.filter_by.current_user.is_in_group group="Members"  />
END IF

I don't know the proper syntax (user identifier) to check to see if the user requesting the serach is not an admin.  I tried this, but it didn't work (error: can't get visitor on cached page):

<n.if.visitor.not.is_site_admin>
            <then>
                <n.filter_by.current_user.is_in_group group="Members"  />
            </then>
</n.if.visitor.not.is_site_admin>

Coleen
Reply | Threaded
Open this post in threaded view
|

Re: Search Users feature

Pedro
It is a bit more complex. Please, try this code:
<macro name="searched_users_list" dot_parameter="do" requires="node_page">      
    <n.site_users. start="0" length="99999">
        <n.filter_by.contains_substring string="[n.to_lower_case.current_user.name/]+[n.to_lower_case.current_user.user_email/]" substring="[n.to_lower_case.searchName/]"/>
        <n.user_request/>       
        <n.do/>
    </n.site_users.>
</macro>

<macro name="user_request">
    <script type="text/javascript">
        var in_group;
        var path = '/template/NamlServlet.jtp?macro=user_response&user=';
        var url = Nabble.userId;
        $.getScript(path+url+Nabble.getClientID() ,function(data){
        posts_today = data;
        in_group = data;
        
        if(in_group == "false") {
        <n.filter_by.current_user.is_in_group group="Members"  />
        }
        });    
        
    </script>
</macro>
<macro name="user_response">
    <n.user_from_get.is_in_group group="Administrators" />
</macro>

<macro name='user_from_get' dot_parameter="do" >
    <n.get_user_from_id. user_id="[n.get_parameter name='user'/]">
        <n.do/>
    </n.get_user_from_id.>    
</macro>
You can put everything in the same file at Naml advanced editor. Note that you already have the macro searched_users_list.
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Search Users feature

Coleen_Astalos
I've installed these.  It works if I'm not signed in as an Admin.  But when I'm signed in as an Admin, I get the same results (filtered to only those users in the Members group).  

If you want to try it on my site (http://forum.sudsol.org) as an Admin, search for "sudsol" there should be lots of records (17 of them), only 4 are in the Members group.

I'll resend you login access to our site incase you don't have it anymore.
Thanks,
Coleen
Reply | Threaded
Open this post in threaded view
|

Re: Search Users feature

Pedro
I made a temporary solution. Please, take look.
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Search Users feature

Coleen_Astalos
Yes, that is working great!  I don't understand the code, but it works, so I guess that's all that matters!

We've got our Nabble system all set up and ready and are transitioning our entire membership base (1000+ users)  from our Yahoogroup to our Nabble system tomorrow.  So hopefully all will go smoothly!

Thanks,
Coleen