Topic-icon Use JFBConnect instead of CB Connect on CB Profilebook

Active Subscriptions:

None
Hi,

We'd like to remove the CB Connect field (Facebook like & share buttons) and replace them with JFBConnect fields. Reason is, JFBConnect is already integrated with AUP and we want to implement a point system for likes and shares based on profile pages. I can't figure out the code required in CB Connect to integrate AUP on like/share, so replacing it with JFBConnect and adding logic seems to be the best choice for us.

Can you please guide us in showing the social media buttons on the CB profiles of each user?
The topic has been locked.
Active Subscriptions:

None
10 years 1 week ago - 10 years 1 week ago #42953 by lyljov
Hi,

I got around the sourcecoast forums and found that it can be easily posted using braces. Thank you for those who asked!

However, I can only see AUP being enabled in both Likes & Comments... I would like an AUP rule for Share, and I'm thinking of fiddling with the code already. I'm not sure how to edit the jfbconnect.js though to add the sharing function. Thoughts?

Also, the Like to AUP only works when I like my own profile. For other profiles that I like, it doesn't even add points to the current user (me). This should be the case since I'm practically liking a page in the website too. I thought I could just add logic to check if the current userid is not me, then add points to another user. Maybe something to do with the AUP function being based on $href?
Last edit: 10 years 1 week ago by lyljov.
The topic has been locked.
Support Specialist
The FB Like and Comment button have a specific callback from Facebook to notify our code that a new Like or Comment has been made. Unfortunately, the Share button doesn't have such a callback that we're aware of (or in their documentation). You can read more about 'subscriptions' (callbacks) in the page below, which lists the ones they support:
developers.facebook.com/docs/reference/j.../FB.Event.subscribe/

Also, the Share and Like button documentation. The Like button specifically calls out the callback functionality:
developers.facebook.com/docs/plugins/share-button
developers.facebook.com/docs/plugins/like-button (see "How do I know when someone clicked on a Like button on my site?")

As for the AUP rules, JFBConnect doesn't limit the rules in any way. We will tell AUP about any Like button clicks on any page. In AUP you *can* configure it different ways for rewarding points, like:
a) Reward points for only the first action
b) Reward points only one time per URL (prevents repeated Liking/Unliking to get points)
c) Reward points for every action

It sounds like you have it configured for a) above. You'll need to consult with AUP and check your Like point reward settings to fix things how you want them to work.

I hope that helps answer your questions,
Alex
The topic has been locked.
Active Subscriptions:

None
10 years 4 days ago #43103 by lyljov
Hi Alex,

It now adds points to the current user. I just had to clear all activity for me to see it.

However, the behavior that we want is when the User clicks the JFBConnect like button of another person's profile, that other person gets the points, not the liker. So the Like button adds points to the user who's profile was liked, not the person who liked the profile.

I know this would require a logic change on the script, since it currently works ok with Articles (when you like an article on the site, it will add points to you). I think I have to check if the URL that's being liked has the $uid parameter other than the current $user->id. Any thoughts on that?
The topic has been locked.
Support Specialist
To update our AUP rules for doing this, you'd need to edit the /components/com_jfbconnect/controllers/social.php file. Around line 82, you'll see:
AlphaUserPointsHelper::newpoints('plgjfbconnect_'.$type.'_new', '', $href);
That blank parameter in the middle can be used to attribute the points to another user, like below for user 123:
AlphaUserPointsHelper::newpoints('plgjfbconnect_'.$type.'_new', 123, $href);

The documentation for the AUP rewarding of points can be found below with more of an explanation of how to get the user id properly, but it's pretty much what I said above. Your idea of checking the URL seems right, and hopefully the above gets you going.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
10 years 2 days ago #43197 by lyljov
Hi Alex,

I've tried the documentation on AUP (using JFactory) but what I'm getting is the userid of the currently logged in user (me), not the userid of the profile I'm liking. Is there a way to get the right user ID?
The topic has been locked.
Support Specialist
You wouldn't use JFactory::getUser() as that will get the current user. Instead, you need to check the URL query string variables. I don't know what the URL looks like, but let's say it's:
index.php?option=com_comprofiler&view=profile&user_id=12
You'd want to use the following code:
if (JRequest::getCmd('option') == 'com_comprofiler' && JRequest::getCmd('view') == 'profile')
   $user_id = JRequest::getInt('user_id');
To get the real URL, do the development with SEF URLs turned off. The code will work even with SEF URLs turned on after you get it working.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
9 years 11 months ago - 9 years 11 months ago #43274 by lyljov
Hi Alex,

I have tried the above solution and it does not work. When editing social.php, the code does not recognize the JRequest if statements (I tried them individually) so the $user_id remains null. The correct URL is:
option=com_comprofiler&task=userprofile&user=1001

So I have already adjusted the if statements for that. I even tried using JInput but it also failed to enter the if statement:
if ($jinput->get('option') == 'com_comprofiler')
{
$user_id=$jinput->get('user');
}

I also tried removing the if statement entirely and just use this before AUP API is instantiated:
$user_id = JRequest::getInt('user');

But it still does not return a value for $user_id. I know the code for adding points works, because I have tried hardcoding a value on $user_id. Any thoughts on why this is happening?
Last edit: 9 years 11 months ago by lyljov.
The topic has been locked.
Support Specialist
I'm going to give a big Wooops here. The problem is that the URL of the page called to send the comment notification isn't the current page. We pass the original URL in though. Can you try the following:
$router = JRouter::getInstance('site');
        $juri = new JURI($url);
        $queryVars = $router->parse($juri);
        $option = isset($queryVars['option']) ? $queryVars['option'] : null;
        $user_id = isset($queryVars['user_id']) ? $queryVars['user_id'] : null;
Then, your if statements should work.

That code is untested, but hopefully just works and gets you going. If you have any questions, just let me know!

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
9 years 11 months ago #43295 by lyljov
Hi Alex,

Here's the code I'm using:
$router = JRouter::getInstance('site');
        $juri = new JURI($url);
        $queryVars = $router->parse($juri);
        $option = isset($queryVars['option']) ? $queryVars['option'] : null;
        $task = isset($queryVars['task']) ? $queryVars['task'] : null;
if ($option == 'com_comprofiler')
{
$user_id = $queryVars['user'];
}

The code still does not fetch the value of the variables in the URL. I was able to prove that by forcing $user_id to be '1001' inside the if statement, and it does not process it.
The topic has been locked.