[SOLVED] blocking other users profile using auto actions

12 years 5 months ago - 12 years 5 months ago #183092 by kalonly
I am using CB 1.7.1 and Groupjive 2.4. For my example i created 4 users with user_id 64, 65,66 and 67.

In Groupjive I created two groups: BU1 en BU2.

64 and 65 and 66 are member of BU1
66 and 67 are member of BU2

As stated in other posts CB allows to view profiles of other registered users with a URL like: www.website.com/index.php?option=com_comprofiler&task=userprofile&user=65&Itemid=53
where 65 can be substituted by any user_id.

I would like to display only the profiles for the users which are in the same Groupjive group (in this example: 64,65 and 66 can see each others profiles, 66 and 67 can see each others profiles).

I tried to make a redirect with the auto actions plugin, but I do not seem to understand the syntax which is used to define the condition. Could you give me hint based on the example above?

Please Log in to join the conversation.

12 years 5 months ago #183105 by krileon
CB Auto Actions can certainly do the redirect, but you meed to calculate the condition first. You'll need incubator project CB Query Field. This provides a new field type that can be created from Field Management and allows you to supply a database query. This field would be used as your condition in your Redirect auto action. Below is example of what your setup should look like.

Query Field
Name: cb_inmygroup (can be changed, just for examples sake)
Query:
SELECT COUNT(*) FROM `#__groupjive_users` WHERE `user_id` = '[cb:userdata field="user_id" user="#me" /]' AND `group` IN ( SELECT `group` FROM `#__groupjive_users` WHERE `user_id` = '[user_id]' )
Mode: Internal

Auto Action
Published: Yes
Type: Redirect
Trigger: onBeforeUserProfileDisplay
User: Automatic
Access: Everybody
Condition 1: [cb_inmygroup] Equal To 0
Condition 2: [user_id] Not Equal To [cb:userdata field="user_id" user="#me" /]
URL: index.php

The above is just an example and may need some changes. Please note I did not test any of this configuration.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 5 months ago #183206 by kalonly
Thanks for the very quick response. When I run the suggested query directy in phpmyadmin, I get the proper results (zero for users which are not in my group and <>0 for users which share a group with me). So far so good.

However, when i make the redirect auto action, nothing is redirected. It seems the query is not (properly) executed. Is there a way to test this?

Maybe I make a mistake. A few (stupid?) questions:
All my tables have dbko as a prefix. I assume I have to substitute #_ with my prefix (which results in select count(*) from `dbko_groupjive_users` ....). Is this a correct assumption?

I assume the query field cb_inmygroup should be publised. Does it matter on which tab (and should this tab be published as well)? And what about the other settings?

The default size for the query field is zero. Is this correct?

Is there a way to test the behaviour (result) of the query field?

Please Log in to join the conversation.

12 years 5 months ago #183213 by nant

Please Log in to join the conversation.

12 years 5 months ago - 12 years 5 months ago #183222 by kalonly
thanks, but that does not solve it. Do you have another suggestion?

EDIT: It is working now. Made a typing error in the SQL. Thanks very much for the solution!!!!!

Please Log in to join the conversation.

12 years 5 months ago #183259 by krileon

Thanks for the very quick response. When I run the suggested query directy in phpmyadmin, I get the proper results (zero for users which are not in my group and <>0 for users which share a group with me). So far so good.

The query I provided won't work in phpymadmin as it's designed to use table prefix replacement and substitutions, both specific to Joomla/CB.

All my tables have dbko as a prefix. I assume I have to substitute #_ with my prefix (which results in select count(*) from `dbko_groupjive_users` ....). Is this a correct assumption?

If the query is in a query field you don't need to add your prefix as #__ will substitute it in for you.

I assume the query field cb_inmygroup should be publised. Does it matter on which tab (and should this tab be published as well)? And what about the other settings?

It needs to be public and published. Doesn't matter which tab it is on. If you don't want it seen on profile then set the tab in a not shown on profile position.

Is there a way to test the behaviour (result) of the query field?

Best way to test is let it display on your profile then simply review your profile as a different user to see if it outputs properly. Otherwise you could convert all the substitutions and prefix replacements so you could run it in phpmyadmin.

EDIT: It is working now. Made a typing error in the SQL. Thanks very much for the solution!!!!!

Thank you for confirming is working. :)


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.286 seconds

Facebook Twitter LinkedIn